0
votes

I want to upgrade symfony 2.8 project to 3.0, i changed the version in composer.json to 3.0.* but after composer update is done, i have these error in console:

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in
/var/www/html/t/EcoPro/app/AppKernel.php on line 6

1
Can we see your app(_dev).php file, and composer json?Federkun

1 Answers

1
votes

It sounds like your code can't find the Kernel class from Symfony. Since it should still be there, as you can see in the Symfony repository in the 3.0-branch I assume something went wrong during your update.

I suggest first running composer diagnose to see if composer itself is up to date and your composer.json is syntactically valid. As a next step you should verify the current version of your dependencies by running composer show. The output should look something like this:

    $ composer show
doctrine/annotations                 v1.2.7  Docblock Annotations Parser
doctrine/cache                       v1.5.1  Caching library offering an object-oriented API for many cache backends
doctrine/collections                 v1.3.0  Collections Abstraction library
doctrine/common                      v2.5.1  Common Library for Doctrine projects
doctrine/dbal                        v2.5.2  Database Abstraction Layer
doctrine/doctrine-bundle             1.6.0   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.2.2   Symfony Bundle for Doctrine Cache
doctrine/inflector                   v1.1.0  Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                1.0.5   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm                         v2.5.2  Object-Relational-Mapper for PHP
incenteev/composer-parameter-handler v2.1.2  Composer script handling your ignored parameter file
jdorn/sql-formatter                  v1.2.17 a PHP SQL highlighting library
monolog/monolog                      1.17.2  Sends your logs to files, sockets, inboxes, databases and various web services
paragonie/random_compat              1.1.0   PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
psr/log                              1.0.0   Common interface for logging libraries
sensio/distribution-bundle           v5.0.2  Base bundle for Symfony Distributions
sensio/framework-extra-bundle        v3.0.11 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle              v3.0.0  This bundle generates code for you
sensiolabs/security-checker          v3.0.2  A security checker for your composer.lock
swiftmailer/swiftmailer              v5.4.1  Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle               v2.8.2  Symfony MonologBundle
symfony/phpunit-bridge               v2.8.0  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu            v1.0.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring            v1.0.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56               v1.0.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70               v1.0.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                v1.0.0  Symfony utilities for portability of PHP codes
symfony/swiftmailer-bundle           v2.3.9  Symfony SwiftmailerBundle
symfony/symfony                      v3.0.0  The Symfony PHP framework
twig/twig                            v1.23.1 Twig, the flexible, fast, and secure template language for PHP

This should help you see whether the update actually worked. If all looks fine, I would go the safe route and revert your code back to 2.8 and then do the update like explained below, instead of changing the composer.json!

First make sure you fixed all deprecations in your existing application. You can use the UPGRADE-document as reference, but also run your tests and check the logs for deprecated calls. This will become easier with 3.3+ as these versions have a separate deprecation-log that you can find in var/log alongside the other log files.

Once you are reasonably sure you code will run with a new major version, just use the following composer command:

composer require symfony/lts:"^3.0"

This is only to make sure that we don't accidentally install any Symfony component that is 4.0 during the process. Once you want to upgrade to Symfony 4 you can just remove this dependency using composer remove symfony/lts and then run update.

After the lts meta package is in place you can update Symfony itself:

composer require symfony/symfony:^3.0

to update to the newest 3.x that your dependencies support or use a stricter constraint if you really want to go step by step:

composer require symfony/symfony:3.0.*

You can also do both things in one step if you like:

$ composer require symfony/lts:^3.0 symfony/symfony:^3.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 2 updates, 0 removals
- Updating symfony/symfony (v2.8.32 => v3.4.2): Downloading (100%)
- Installing psr/simple-cache (1.0.0): Loading from cache
- Installing psr/link (1.0.0): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing fig/link-util (1.0.0): Loading from cache
Writing lock file
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache

// Clearing the cache for the dev environment with debug
// true


[OK] Cache for the "dev" environment (debug=true) was successfully cleared.


> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets

Trying to install assets as relative symbolic links.


[OK] No assets were provided by any bundle.


> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget

This should already be enough to have Symfony on the newer version. You will likely have other dependencies such as Doctrine or some bundles that you have installed as well. There are a few useful commands for updating them.

First you can update only a single dependency at a time:

composer update doctrine/orm

When you add the option --with-dependencies it will also update doctrine/orm's dependencies.

You can always ask composer why or composer why-not with a dependency and optionally a version to check why a dependency is there and why it won't update. Just type composer help why-not to see how to use it. This is particularly helpful when you want to update a dependency like doctrine/orm, but composer throws an error that it can't do it.