Я пытаюсь развернуть приложение Symfony на Heroku, но когда я запускаю команду git push heroku master
Я получаю ошибку:
Неопознанная ошибка: класс ‘Doctrine \ Bundle \ FixturesBundle \ DoctrineFixturesBundle’ не найден в /tmp/build_808fab60090f288d282076c72569d1ad/app/AppKernel.php:19
Журнал ошибок:
Generating optimized autoload files
remote: > Incenteev\ParameterHandler\ScriptHandler::buildParameters
remote: Creating the "app/config/parameters.yml" file
remote: > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
remote: > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
remote: PHP Fatal error: Uncaught Error: Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found in /tmp/build_808fab60090f288d282076c72569d1ad/app/AppKernel.php:19
remote: Stack trace:
remote: #0 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(450): AppKernel->registerBundles()
remote: #1 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(116): Symfony\Component\HttpKernel\Kernel->initializeBundles()
remote: #2 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(137): Symfony\Component\HttpKernel\Kernel->boot()
remote: #3 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(124): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
remote: #4 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(90): Symfony\Bundle\Framewor in /tmp/build_808fab60090f288d282076c72569d1ad/app/AppKernel.php on line 19
remote: Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
remote:
remote:
remote: [RuntimeException]
remote: An error occurred when executing the "'cache:clear —no-warmup'" command:
remote:
remote:
remote:
remote: PHP Fatal error: Uncaught Error: Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found in /tmp/build_808fab60090f288d282076c72569d1ad/app/AppKernel.php:19
remote: Stack trace:
remote: #0 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(450): AppKernel->registerBundles()
remote: #1 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(116): Symfony\Component\HttpKernel\Kernel->initializeBundles()
remote: #2 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(137): Symfony\Component\HttpKernel\Kernel->boot()
remote: #3 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(124): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
remote: #4 /tmp/build_808fab60090f288d282076c72569d1ad/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(90): Symfony\Bundle\Framewor in /tmp/build_808fab60090f288d282076c72569d1ad/app/AppKernel.php on line 19
remote:
remote:
remote: install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
remote:
remote: ! WARNING: There was a class not found error in your code
remote:
remote: ! ERROR: Dependency installation failed!
мой AppKernel::registerBundles()
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Knp\DoctrineBehaviors\Bundle\DoctrineBehaviorsBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
}
return $bundles;
}
composer.json (блоки «require»)
{
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-migrations-bundle": "^1.3",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"knplabs/doctrine-behaviors": "^1.4",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0"},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"}
}
Что мне нужно сделать?
Вы установили «doctrine / doctrine-fixtures-bundle» для разработки:
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"},
Но пытаются использовать его в производстве.
При развертывании вашего приложения heroku устанавливает зависимости композитора с помощью --no-dev
флаг, который пропускает пакеты, объявленные в require-dev
,
Когда приложение пытается запустить AppKernel::registerBundles()
Буду пытаться создать экземпляр Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle
, но этот пакет не установлен.
Вы должны удалить вашу строку 19 (new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
) и добавьте его где-нибудь в следующем блоке:
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
// ^^^^^ this line here
Это проверяет, что среда либо dev
или же test
и только пытаясь использовать эти пакеты, если в этих средах.
Других решений пока нет …