-2

I am trying to upload my symfony project to the server but passing it to dev gives me this error.

composer install --no-dev --optimize-autoloader

PS C:\Users\adria\Desktop\bebeBB>  composer install --no-dev --optimize-autoloader
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating optimized autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
51 packages you are using are looking for funding.
Use the composer fund command to find out more!   
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#33
!!    #message: """
!!      Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle".\n
!!      Did you forget a "use" statement for another namespace?
!!      """
!!    #code: 0
!!    #file: "C:\Users\adria\Desktop\bebeBB\src\Kernel.php"
!!    #line: 23
!!    trace: {
!!      C:\Users\adria\Desktop\bebeBB\src\Kernel.php:23 {
!!        App\Kernel->registerBundles(): iterable
!!        › if ($envs[$this->environment] ?? $envs['all'] ?? true) {
!!        ›     yield new $class();
!!        › }
!!      }
!!      C:\Users\adria\Desktop\bebeBB\vendor\symfony\http-kernel\Kernel.php:369 { …}
!!      C:\Users\adria\Desktop\bebeBB\vendor\symfony\http-kernel\Kernel.php:123 { …}
!!      C:\Users\adria\Desktop\bebeBB\vendor\symfony\framework-bundle\Console\Application.php:168 { …}
!!      C:\Users\adria\Desktop\bebeBB\vendor\symfony\framework-bundle\Console\Application.php:74 { …}
!!      C:\Users\adria\Desktop\bebeBB\vendor\symfony\console\Application.php:140 { …}
!!      C:\Users\adria\Desktop\bebeBB\bin\console:42 { …}
!!    }
!!  }
!!
Script @auto-scripts was called via post-install-cmd

In the Symfony documentation it says to run export APP_ENV = prod but it puts me that the term 'export' is not recognized as the name of a cmdlet

  • `export` is a [`bash` thing](https://stackoverflow.com/questions/61820244#comment109345716_61820244). Either your `.env` file is not configured and is defaulting to the `dev` environment, or the bundles are incorrectly configured (unlikely, since flex should take care of it). Try running `composer dump-env prod` first and try again. And check `config/bundles.php` and search for `MakerBundle` to see in what envs it's active. – msg May 20 '20 at 18:33
  • I've run `composer dump-env prod` and perfect, but running `composer install --no-dev --optimize-autoloader` gives me this error: In AbstractMySQLDriver.php line 106: !! !! An exception occurred in driver: SQLSTATE[HY000] [1130] Host 'static-191-209-229-77.ipcom.comunitel.net' is not allowed to connect to this My !! SQL server – adrianmellado06 - INSTAGRAM May 21 '20 at 10:11
  • Check your environment variables, specially `DATABASE_URL`. Your server doesn't accept connections from the configured interface, maybe try `localhost` or contact support. – msg May 21 '20 at 10:32
  • 1
    What have you tried to debug the problem? Looks like your kernel tries to run some bundle that has not been installed – Nico Haase May 21 '20 at 12:14

2 Answers2

0

Following up on @Reknil's answer, which put me on the right path:

For bash on OSX, this worked:

$ APP_ENV=prod composer install --no-dev

My .env file had APP_ENV=dev, so adding the APP_ENV=prod overrides the environment just for that command.

For PowerShell, I'm not sure how to set the environment var just for a single command. This SO post has some options.

Cheers, jz


fyi, if I run without the APP_ENV=prod, I get the following:

$ composer install --no-dev
Installing dependencies from lock file
...

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#69
!!    #message: """
!!      Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".\n
J.Z.
  • 882
  • 9
  • 13
-1

Check you file .env: Must be: APP_ENV=prod

So, make sure, you environments must be PROD mode

  • Also you can check environments on you WEB Server. For example you environment variables can provide by Nginx (fastcgi_param APP_ENV prod) In any case, the problem is that the environment is not PROD – Reknil Linker May 20 '20 at 12:29
  • 1
    Please add some further explanation to your answer such that others can learn from it – Nico Haase May 21 '20 at 12:14