Closed mpdude closed 3 years ago
@mpdude what's your Symfony version? I'm facing a similar problem after upgrading from Symfony 5.2 to 5.3
Same for me after upgrading to SF 5.3, I couldn't find any good solution beside of this dirty hack:
if($_ENV["APP_ENV"] !== "test") {
class AppFixtures {
//EMPTY
}
} else {
class AppFixtures extends Fixture {
//Real fixtures go here
}
}
Edit: Nevermind, the workaround in the first post is better (autowire the classes in the services_dev.yaml).
@arneee another hack: remove your fixtures folder on your deployment script/process
I'm experiencing a similar issue after upgrading to Symfony 5.3.
When I run the following commands:
composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
composer dump-autoload --classmap-authoritative --no-dev
composer symfony:dump-env prod
composer run-script --no-dev post-install-cmd
I get this error:
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In ClassExistenceResource.php line 74:
!!
!! Class "Doctrine\Bundle\FixturesBundle\Fixture" not found while loading "App
!! \DataFixtures\AppFixtures".
!!
!!
!!
Script @auto-scripts was called via post-install-cmd
Steps to reproduce:
With Symfony 5.2
symfony new symfony-5.2 --version=5.2 --full
cd symfony-5.2
composer require --dev orm-fixtures
composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
composer dump-autoload --classmap-authoritative --no-dev
composer symfony:dump-env prod
composer run-script --no-dev post-install-cmd
With Symfony 5.3
symfony new symfony-5.3 --version=5.3 --full
cd symfony-5.3
composer require --dev orm-fixtures
composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
composer dump-autoload --classmap-authoritative --no-dev
composer symfony:dump-env prod
composer run-script --no-dev post-install-cmd
Here another workaround without creating a separate services_dev.yaml
// services.yaml
services:
// ...
App\:
resource: "../src/"
exclude:
- "../src/DataFixtures/" # exclude by default
- "../src/DependencyInjection/"
- "../src/Entity/"
- "../src/Kernel.php"
- "../src/Tests/"
// ...
when@dev:
services:
_defaults:
autowire: true
autoconfigure: true
App\DataFixtures\:
resource: '../src/DataFixtures/'
Duplicate of https://github.com/symfony/symfony/issues/41548, fixed by https://github.com/symfony/symfony/pull/41673
The documentation at https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html suggests to install this bundle as a
--dev
dependency and to use Symfony Autowiring to register fixtures. That is, theservices
section for example inconfig.yml
looks similar to this:This way, fixtures from the
App/Fixtures
directory will be defined as services and tagged appropriately.When using
composer install --no-dev
in production, the entire bundle is not installed, but theFixtures
directory is still scanned. This causes the following error:Is this a configuration issue on my side or a glitch in the documentation?
As a workaround, you can exclude the
Fixtures
directory from autowiring and use a dedicated section inconfig_dev.yml
(for example) to add it back again. Are there any better solutions?