Why can’t my deployed Symfony application load the bundles.php file?

I have a Symfony webapplication that I would like to deploy to a virtual private server.

I’ve developed the application in a Laravel Homestead Vagrant box, and I’m doing the deployment via Github actions.

On my local machine the app runs fine in the Vagrant environment, but after syncing the files to the live server it gives me an error screen.

Warning: require(/var/www/thebedechkacase.com/src/config/bundles.php): failed to open stream: No such file or directory

The error is coming from line 20 of Kernel.php, which looks like this



        const CONFIG_EXTS = '.{php,xml,yaml,yml}';
        public function registerBundles()
        {
            $contents = require $this->getProjectDir().'/config/bundles.php';
            foreach ($contents as $class => $envs) {
                if ($envs[$this->environment] ?? $envs['all'] ?? false) {
                    yield new $class();
                }
        }

What I don’t understand is that according to the error message and the code above, the output of $this->getProjectDir() resolves to /var/www/thebedechkacase.com/src/ (thebedechkacase.com is the folder where my application code is stored), but bundles.php is actually located in /var/www/thebedechkacase.com/config/.

Why does Symfony think that the projectDir is in src and why doesn’t it look for config in the root directory (aka thebedechkacase.com/)? Why is this working in my dev environment, but not on the live server?

Additional info: I’m trying to set up the necessary environment variables with a shell script that I’m calling in my github action, but when I check the environment variables manually on the live server’s shell, I see that non of them get set, so my script is probably broken in the first place (that’s why you’re able to see the default Symfony error page). Can that have something to do with this or this is another error?

URL where you can see the error:
https://thebedechkacase.com/

Github repo of the project:
https://github.com/Cooty/the-bedechka-case

The action that deploys the code:
https://github.com/Cooty/the-bedechka-case/blob/develop/.github/workflows/main.yml

Symfony version: 5.0

The live server is running Ubuntu 20.04, Ngingx with PHP-FPM 7.4 and PHP 7.4.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *