Closed tsantos84 closed 9 months ago
@tsantos84 hello!
Can you show content of your public/index.php
file?
Sure.
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
But, after debugging the problem I found that opcache
is causing the error. I've just comment the opcache
line on Dockerfile and the error stopped. I'm assuming that on production the absense of opcache
wont impact on performance once the app is loaded in memory with Frankenphp worker mode, right?
Yes, but having Opcache still has benefits (faster worker boot time etc), and that's a very weird issue. Are you able to provide a reproducer? That would be nice to report this issue to PHP.
Sure, I will try to create a reproducer. Basically the same Dockerfile, it means based on dunglas/frankenphp:1-alpine
, right?
Anything allowing them to reproduce would likely interest them!
Could you check if switching to Debian fixes the issue by the way? Moving to Debian is on the roadmap: #555
Anything allowing them to reproduce would likely interest them!
@dunglas , I've found the issue. The problem happens when we provide a nonexistent file to opcache.preload
(and that was my case).
I've managed to reproduce the issue by using this repo and make a small change on it. The step 3
is the offender.
dunglas/symfony-docker
instructions and run the app on dev environmentdocker compose down
frankenphp/conf.d/app.prod.ini
and provide a nonexistent file to opcache.preload
(eg. /foo/bar.php)docker compose -f compose.yaml -f compose.prod.yaml build --no-cache
compose.prod.yaml
docker compose -f compose.yaml -f compose.prod.yaml up -d
After that you will see the following log on app's container:
{"level":"error","ts":1709164144.1067986,"msg":"PHP Fatal error: Uncaught Error: Call to undefined function dirname() in /app/public/index.php:5\nStack trace:\n#0 {main}\n thrown in /app/public/index.php on line 5","syslog_level":"err"}
Could you check if switching to Debian fixes the issue by the way? Moving to Debian is on the roadmap: #555
No, the weird behavior happens on Debian as well. I've tried to build an official PHP image, install opcache and provide a wrong filename for opcache.preload
but the issue does not happen. 🫤
I don't know if the issue resides on Frankenphp + Opcache + wrong filename
or just PHP + Opcache + wrong filename
. In this case, I don't believe that dunglas/symfony-docker
should fix the issue and this issue could be closed. I'll let you decide what to do with it, ok? (close it or keep it opened)
Let me know if I should open an issue directly on Frankenphp repository or official PHP.
I think that official PHP is more appropriate.
I'm adapting an existing Symfony 7 application to use Docker + Frankenphp based on your setup. The
dev
environment works nicely but when I try to run theprod
environment, which uses workers to handle the requests, I'm getting the strange errorPHP Fatal error: Uncaught Error: Call to undefined function dirname() in /app/public/index.php
. This is strange becausedirname
is a built-in PHP's function.Full error:
Caddyfile:
worker.Caddyfile
FRANKENPHP_CONFIG
Dockerfile