Your proxy directory "/tmp" must be writable
Every entity with a composite key cannot use an id generator other than "NONE". That means the ID fields have to have their values set before you call EntityManager#persist($entity)
set_error_handler(function(){
return true;
});
Debug::enable()
) в Symfony error_get_last
работает корректноfunction read($filename)
{
if (!is_file($filename)) {
throw new \Exception();
}
if (($content = @file_get_contents($filename)) === false) {
throw new \Exception(error_get_last()['message']);
}
return $content;
}
$content = @file_get_contents($filename);
$data = json_decode($content, true);
$content = @file_get_contents($filename);
if ($content !== false) {
$data = json_decode($content, true);;
} else {
// Обработка отсутствия файла
}
$start = microtime(true);
function read($filename)
{
set_error_handler(function () {});
try {
return file_get_contents($filename);
} finally {
restore_error_handler();
}
}
for ($i = 0; $i < 100000; $i++) {
$filename = $i . '.txt';
$content = read($filename);
}
// double(3.5031039714813)
var_dump(microtime(true) - $start);
$start = microtime(true);
for ($i = 0; $i < 100000; $i++) {
$filename = $i . '.txt';
$content = @file_get_contents($filename);
}
var_dump(microtime(true) - $start);
$start = microtime(true);
for ($i = 0; $i < 100000; $i++) {
$filename = $i . '.txt';
if (file_exists($filename)) {
$content = file_get_contents($filename);
}
}
var_dump(microtime(true) - $start);
$start = microtime(true);
for ($i = 0; $i < 100000; $i++) {
$filename = $i . '.txt';
set_error_handler(function(){
throw new \LogicException();
});
try {
$content = file_get_contents($filename);
} catch (\LogicException $e) {
}
restore_error_handler();
}
var_dump(microtime(true) - $start);