This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
symfony new --full my_project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$password = 'rasmuslerdorf'; | |
$hash = '$2y$10$YCFsG6elYca568hBi2pZ0.3LDL5wjgxct1N8w/oLR/jfHsiQwCqTS'; | |
// O parâmetro cost pode mudar com o tempo, à medida que o hardware melhora | |
$options = array('cost' => 11); | |
// Verificar hash armazenado contra senha de texto sem formatação | |
if (password_verify($password, $hash)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Verifique o hash que provavelmente deve vir do banco | |
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq'; | |
if (password_verify('rasmuslerdorf', $hash)) { | |
echo 'Senha é válida!'; | |
} else { | |
echo 'Senha é inválida.'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Nesse caso, queremos aumentar o custo padrão do BCRYPT para 12. | |
// Observe que também mudamos para BCRYPT, que sempre terá 60 caracteres. | |
$options = [ | |
'cost' => 12, | |
]; | |
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opache.validate_timestamps = 1 //"0" em ambiente de produção | |
opache.revalidate_freq = 0 | |
opache.memory_consumption = 64 | |
opache.interned_strings_buffer = 16 | |
opache.max_accelerated_files = 4000 | |
opache.fast_shutdown = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Simulation configuration | |
$config['uppercase'] = true; | |
$lambda = function ($first, $second) { | |
return $first + $second; | |
}; | |
$result_lambda = $lambda(2, 3); | |
echo $result_lambda; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getRows($file) { | |
$handle = fopen($file, 'rb'); | |
if (!$handle) { | |
throw new Exception(); | |
} | |
while (!feof($handle)) { | |
yield fgetcsv($handle); | |
} | |
fclose($handle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function xrange($start, $limit, $step = 1) { | |
if ($start < $limit) { | |
if ($step <= 0) { | |
throw new LogicException('O passo deve ser positivo'); | |
} | |
for ($i = $start; $i <= $limit; $i += $step) { | |
yield $i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function meuGenerator(){ | |
yield 'valor1'; | |
yield 'valor2'; | |
yield 'valor3'; | |
} | |
foreach (meuGenerator() as $yieldValor) { | |
echo $yieldValor, PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Base { | |
public function digaOla() { | |
echo 'Olá '; | |
} | |
} | |
trait DigaOla { | |
public function digaOla() { |
NewerOlder