1

I am deploying Symfony 4 website on a 1&1 server shared hosting. and I am facing an error which I guess is link with the autoload that cannot compile the good path that is given to it.

So it seems that in the first path between "composer" and "symfony", there is "../" to actually leave the composer directory and then go to the symfony one, but it is compiling instead of changing directory.

I transfered my project with Filezilla.

Before the transfer I prepared my project by changing .env to prod and DB connection. But I also executed this command :

composer install --no-dev --optimize-autoloader
composer dump-autoload --optimize --no-dev --classmap-authoritative

Many thanks for your help in advance

The error shown is :

Fatal error: require(): Failed opening required '/homepages/xx/xxxxxxxx/htdocs/snowtricks/vendor/composer/../symfony/phpunit-bridge/bootstrap.php' (include_path='.:/usr/lib/php7.2') in /homepages/xx/xxxxxxx/htdocs/snowtricks/vendor/composer/autoload_real.php on line 66

MaxiGui
  • 6,190
  • 4
  • 16
  • 33
  • 1
    Possible duplicate of [PHP Fatal Error Failed opening required File](https://stackoverflow.com/questions/5364233/php-fatal-error-failed-opening-required-file) – Sachin Yadav Oct 10 '19 at 17:03
  • I dont really how it will solve my problem... I dont use any edit, so except if you give me more details about it... I cannot solve it... – MaxiGui Oct 10 '19 at 19:05
  • 1
    please set `SYMFONY_ENV` to `prod` and add `--no-dev` option when installing dependencies by the composer. – Mohammad Zare Moghadam Oct 10 '19 at 19:51
  • 1
    How did you transfer the files to your host? Have you checked if the (read-)permissions are set correctly and the file exists (in vendor/symfony/...)? The phpunit-bridge is usually a dev dependency, should the application run in prod as @MohammadZareMoghadam suggests? – dbrumann Oct 11 '19 at 04:41
  • 1
    I'm not sure if 1&1 shared hosting comes with 'composer' installed. I would suggest that you upload the project with **vendor** files & folder. If it working on your local machine, it should work on your shared hosting too. – Aakash Tushar Oct 11 '19 at 06:16
  • hi, I was transfering with FileZilla. Composer is not installed on 1&1 shared server but I could install. But the use of it is pretty limited because shell PHP version is 4.4.9... – MaxiGui Oct 11 '19 at 06:51
  • 1 - permissions is fine 2 - after running the command : `php7.1-cli ../composer.phar dump-autoload --no-dev` in the directory of my project, I got a new error but similar : `Fatal error: require(): Failed opening required '/homepages/xx/xxxxxxxx/htdocs/snowtricks/vendor/composer/../symfony/polyfill-intl-icu/bootstrap.php' (include_path='.:/usr/lib/php7.2') in /homepages/xx/xxxxxxxx/htdocs/snowtricks/vendor/composer/autoload_real.php on line 66` – MaxiGui Oct 11 '19 at 07:07
  • In order to give more details, I also execute the command in my server project directory : `php7.1-cli ../composer.phar install` and I got this error `Executing script cache:clear [KO] [KO] Script cache:clear returned with error code 255` and under the same error as above – MaxiGui Oct 11 '19 at 07:26
  • php version clash + server believing it's in dev env – Jakumi Oct 11 '19 at 07:44
  • @Jakumi so you think I should try to delete the whole directory and update it again ? – MaxiGui Oct 11 '19 at 07:58
  • I would say you need a dev machine with the same (or close) php version, set that version in your composer.json and run composer on the server (with --no-dev) and set the env there correctly – Jakumi Oct 11 '19 at 08:00
  • @Jakumi Thank you version is actualy the same and env is set correctly... – MaxiGui Oct 11 '19 at 08:40
  • in that case it all works. congratulations ;o) (hint, you ran `php7.1-cli` on your server, and the include path when doing so is `/usr/lib/php7.2`, so there is *some* mismatch) - I hope you are aware, that .env is not always used to determine the env right? – Jakumi Oct 11 '19 at 08:47
  • @Jakumi yes I was trying different way with to set APP_ENV, htaccess,, index or parameters.yaml, still the same there. So I was in my server settings to check (and I change from 7.2 to 7.1) that and now I am getting same message but with 7.1 `Fatal error: require(): Failed opening required '/homepages/30/d787425622/htdocs/snowtricks/vendor/composer/../symfony/polyfill-intl-icu/bootstrap.php' (include_path='.:/usr/lib/php7.1') in /homepages/30/d787425622/htdocs/snowtricks/vendor/composer/autoload_real.php on line 66` – MaxiGui Oct 11 '19 at 09:39
  • it looks like the symfony/polyfill-intl-icu vendor package is missing, although it is expected to be there. so something in your upload process or install process is not working as expected – Jakumi Oct 11 '19 at 10:26
  • Actualy, those files and folder exist. But as you can in the 1st path, it does not compile well and it is adding ../ betweencompile and symfony. Like if the basic way will start from compile and it wants to go up from one level but it is just pasting the way instead – MaxiGui Oct 11 '19 at 10:37
  • actually, that's absolutely correct.`/vendor/composer/../symfony/` translates to `/vendor/symfony/` ... – Jakumi Oct 11 '19 at 10:57
  • @Jakumi yeah you right, I checked again and it seems that the transfer did not transfered all the files correctly. – MaxiGui Oct 11 '19 at 11:44

1 Answers1

1

So I had multiple issues, many thanks for thos who help me in the comments. The first thing to do was to run the command php7.1-cli ../composer.phar dump-autoload --no-devas @Mohammad Zare Moghadam suggest:

please set SYMFONY_ENV to prod and add --no-dev option when installing dependencies by the composer. – Mohammad Zare Moghadam

And then it seems that the files were really missing even if I did the transfer with FileZilla, I must manage every bundle manualy again.

Thanks to @Jakumi for his patient.

MaxiGui
  • 6,190
  • 4
  • 16
  • 33