Symfony 5.4 missing Dev bundles in Production - php

I want to deploy my symfony application in production using the command composer install require --no-dev however I get the following error :
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#97
#message: """
Attempted to load class "NelmioAliceBundle" from namespace "Nelmio\Alice\Bridge\Symfony".\n
Did you forget a "use" statement for another namespace?
"""
#code: 0
#file: "/Users/tom/Documents/test-rh-rh/www/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php"
#line: 132
trace: {
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:132 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/http-kernel/Kernel.php:386 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/http-kernel/Kernel.php:786 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/http-kernel/Kernel.php:128 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/framework-bundle/Console/Application.php:168 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/framework-bundle/Console/Application.php:74 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/console/Application.php:171 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
/Users/tom/Documents/test-rh-rh/www/vendor/autoload_runtime.php:35 { …}
/Users/tom/Documents/test-rh-rh/www/bin/console:11 {
I tried to specify the environment by adding SYMFONY_ENV=prod as specified in the doc but without success.
how do I deploy production bundles only?

Related

"Class not found" error when deploying Symphony to Heroku

When I try to deploy my code to heroku (git), my deployment fails with the following error message:
Generating optimized autoload files
83 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#70
!! #message: """
!! Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".\n
!! Did you forget a "use" statement for another namespace?
!! """
!! #code: 0
!! #file: "./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php"
!! #line: 132
!! trace: {
!! ./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:132 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:386 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:786 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:128 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!! ./vendor/symfony/console/Application.php:171 { …}
!! ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
!! ./vendor/autoload_runtime.php:35 { …}
!! ./bin/console:11 {
!! ›
!! › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "/tmp/build_bdf9f8d3/vendor/autoload_runtime.php"
!! }
!! }
!! }
!! }
!! 2022-08-27T11:43:06+00:00 [critical] Uncaught Error: Class "Symfony\Bundle\DebugBundle\DebugBundle" not found
!!
Script #auto-scripts was called via post-install-cmd
! ERROR: Dependency installation failed!
!
! The 'composer install' process failed with an error. The cause
! may be the download or installation of packages, or a pre- or
! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
! in your 'composer.json'.
!
! Typical error cases are out-of-date or missing parts of code,
! timeouts when making external connections, or memory limits.
!
! Check the above error output closely to determine the cause of
! the problem, ensure the code you're pushing is functioning
! properly, and that all local changes are committed correctly.
!
! For more information on builds for PHP on Heroku, refer to
! https://devcenter.heroku.com/articles/php-support
! Push rejected, failed to compile PHP app.
! Push failed

Can not load class "Kernel" from namespace "App" [duplicate]

I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue

failure during clear cash using symfony 4

i'm new to symfony i tried to install package admin panel by command composer require admin but it gives me error The deprecation template must contain the “% service_id%” placeholder, i executed command composer update, and found some answer ( Updating easycorp/easyadmin-bundle, Updating doctrine/doctrine-migrations-bundle, Updating symfony/orm-pack) I tried these command but it gives me error:
Fatal error: Declaration of ContainerLTFhDJN\EntityManager_9a5be93::getProxyInitializer() must be compatible with ProxyManager\Proxy\LazyLoadingInterface::getProxyInitializer(): ?Closure in D:
\wamp\www\symfony4\var\cache\dev\ContainerLTFhDJN\srcApp_KernelDevDebugContainer.php on line 5876
Symfony\Component\ErrorHandler\Error\FatalError^ {#33
-error: array:4 [
"type" => 64
"message" => "Declaration of ContainerLTFhDJN\EntityManager_9a5be93::getProxyInitializer() must be compatible with ProxyManager\Proxy\LazyLoadingInterface::getProxyInitializer(): ?Closure"
"file" => "D:\wamp\www\symfony4\var\cache\dev\ContainerLTFhDJN\srcApp_KernelDevDebugContainer.php"
"line" => 5876
]
#message: "Compile Error: Declaration of ContainerLTFhDJN\EntityManager_9a5be93::getProxyInitializer() must be compatible with ProxyManager\Proxy\LazyLoadingInterface::getProxyInitializer():
?Closure"
#code: 0
#file: "D:\wamp\www\symfony4\var\cache\dev\ContainerLTFhDJN\srcApp_KernelDevDebugContainer.php"
#line: 5876
}
I had a similar problem after updating some doctrine package. Removing var/cache fixed it for me.

Clear cache command gets an error error after installing api-platform.com [duplicate]

This question already has an answer here:
"Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory::__construct() must be an instance..."
(1 answer)
Closed 2 years ago.
I'm trying to install api-platform but I'm having problems after launching my composer install:
I follow the official docs for installation with:
composer req api
When I start the server or when I try to run composer install I get this error:
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
and then a warning:
[WARNING] Some commands could not be registered:
!!
!!
!! In DoctrineOrmPropertyMetadataFactory.php line 31:
!!
!! Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property
!! \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D
!! octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc
!! trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co
!! ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
!!
!!
!! In DoctrineOrmPropertyMetadataFactory.php line 31:
!!
!! Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property
!! \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D
!! octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc
!! trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co
!! ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
!!
!!
!! [WARNING] Some commands could not be registered:
!!
!!
!! In DoctrineOrmPropertyMetadataFactory.php line 31:
!!
!! Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property
!! \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D
!! octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc
!! trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co
!! ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
!!
!!
!! In DoctrineOrmPropertyMetadataFactory.php line 31:
!!
!! Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property
!! \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D
!! octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc
!! trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co
!! ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
!!
!!
!! // Clearing the cache for the dev environment with debug
!! // true
!!
!!
!! In DoctrineOrmPropertyMetadataFactory.php line 31:
!!
!! Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property
!! \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D
!! octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc
!! trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co
!! ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!
!! 2020-08-25T12:06:30+02:00 [critical] Uncaught Error: Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/ContainerPA69O1T/App_KernelDevDebugContainer.php on line 1040
Why am I getting this error, and what can I do to circumvent it?
NEWS : It Seems that adding these lines in your composer.json at the conflict property works !
"conflict": {
"symfony/symfony": "*",
"doctrine/common": ">=3.0",
"doctrine/persistence": "<1.3"
},
So i got this problem since this morning and i looked for a solution and didn't found it so i made my own DIY solution and it's working Pretty find for me Then i'm gonna share it :
Firstly you need to go in the following path and open the file in it with your code editor:
C:\YOUR_PROJECT\vendor\api-platform\core\src\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory.php
Once you opened it, you need to REPLACE the line 19 (use Doctrine\Common\Persistence\ManagerRegistry;) with the following one:
use Symfony\Bridge\Doctrine\ManagerRegistry;
AND THAT'S ALL FOLKS !
SCREENSHOT OF THE LINE
PS: If you're still having issues or not founding the Vendor\api-platform, you just need to open the composer.json and temporary delete the Following line :
"cache:clear": "symfony-cmd",
And run again the command:
composer req api
we have the same problem since yesterday!
I tried to change the version of the bundle, to an older version . But without any successful result.
Current dependency:
"api-platform/api-pack": "^1.2"
But the problem is solved on GitHub. To be tested...
https://github.com/symfony/symfony/issues/37936
UPDATE: We have to wait for a release of api-platform bundle.
https://github.com/api-platform/core/issues/3683
Temporarily, you can add this to composer.json :
"conflict": {
...
"doctrine/common": ">=3.0",
"doctrine/persistence": "<1.3"
}
It works for me.
https://github.com/api-platform/core/issues/3683#issuecomment-681039267
I have the same problem but when i add the following lines
"conflict": { ... "doctrine/common": ">=3.0", "doctrine/persistence": "<1.3" }
in my composer.json file the problem was resolved

Uncaught Error: Class 'App\Kernel' not found

I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue

Categories