简体   繁体   English

从Symfony 2.8迁移到3.0

[英]Symfony 2.8 to 3.0 migration

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: 我想将symfony 2.8项目升级到3.0 ,我将composer.json的版本更改为3.0.*但是在完成composer更新后,控制台中出现以下错误:

[RuntimeException] [RuntimeException的]
An error occurred when executing the "'cache:clear --no-warmup'" command: 执行“'cache:clear --no-warmup'”命令时发生错误:
PHP Fatal error: Class 'Symfony\\Component\\HttpKernel\\Kernel' not found in PHP致命错误:找不到类'Symfony \\ Component \\ HttpKernel \\ Kernel'
/var/www/html/t/EcoPro/app/AppKernel.php on line 6 /var/www/html/t/EcoPro/app/AppKernel.php,第6行

It sounds like your code can't find the Kernel class from Symfony. 听起来您的代码无法从Symfony中找到Kernel类。 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. 因为它仍然应该存在,所以您可以在3.0分支Symfony存储库中看到,我认为在更新期间出现了问题。

I suggest first running composer diagnose to see if composer itself is up to date and your composer.json is syntactically valid. 我建议首先运行composer diagnose以查看作曲家本身是否最新并且您的composer.json在语法上是有效的。 As a next step you should verify the current version of your dependencies by running composer show . 下一步,您应该通过运行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! 如果一切正常,我将按照安全路线进行操作,将您的代码恢复为2.8,然后按以下说明进行更新,而不是更改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 . 您可以使用UPGRADE文档作为参考,但也可以运行测试并检查日志以了解不赞成使用的呼叫 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. 对于3.3+版本,这将变得更加容易,因为这些版本具有单独的弃用日志 ,您可以在var/log与其他日志文件一起找到。

Once you are reasonably sure you code will run with a new major version, just use the following composer command: 一旦确定可以使用新的主要版本运行代码,只需使用以下composer命令:

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. 这只是为了确保在此过程中我们不会意外安装任何4.0版本的Symfony组件。 Once you want to upgrade to Symfony 4 you can just remove this dependency using composer remove symfony/lts and then run update. 一旦您想升级到Symfony 4,就可以使用composer remove symfony/lts来删除此依赖项,然后运行update。

After the lts meta package is in place you can update Symfony itself: 放置lts meta包后,您可以更新Symfony本身:

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: 更新到您的依赖项支持的最新3.x或使用更严格的约束(如果您确实想逐步进行):

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. 这应该已经足够在新版本上安装Symfony。 You will likely have other dependencies such as Doctrine or some bundles that you have installed as well. 您可能还会有其他依赖项,例如Doctrine或已安装的某些捆绑包。 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. 当您添加--with-dependencies选项时,它还会更新主义/ orm的依赖关系。

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. 您总是可以询问composer whycomposer why-not提供依赖项,还可以选择版本,以检查为什么存在依赖项以及为什么不更新依赖项。 Just type composer help why-not to see how to use it. 只需输入composer help why-not如何使用它。 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. 当您要更新诸如doctrine / orm之类的依赖项时,此功能特别有用,但是composer会抛出一个无法做到的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Symfony 2.8升级到3.0时出错 - Error upgrading symfony 2.8 to 3.0 在 Symfony 2.8、3.0 及更高版本中将数据传递给 buildForm() - Passing data to buildForm() in Symfony 2.8, 3.0 and above Symfony2.8->3.0:请求格式覆盖方法 - Symfony2.8->3.0: Request format override method Symfony 2.8 / 3.0-将数组从collectionType传递到另一个formType - Symfony 2.8/3.0 - Pass array to another formType from a collectionType 形式从 symfony2.8 升级到 3.0 时向后兼容性中断 - Backward compatibility breaks in forms upgrading from symfony2.8 to 3.0 使用 Symfony 升级 2.8-> 3.4 进行学说迁移时出错 - Error while Doctrine Migration with Symfony upgrade 2.8-> 3.4 Symfony:stof/doctrine-extensions-bundle 与 Symfony 从 v2.8 升级到 v3.0 不兼容 - Symfony: stof/doctrine-extensions-bundle incompatible with Symfony upgrade from v2.8 to v3.0 将Symfony2.8更新到Symfony3.0时,如何设置新的目录结构? - How can I set the new directory structure when updating Symfony2.8 to Symfony3.0? “保留的指示符”@“不能启动纯标量”——在 YML 文件中。 (升级 SYMFONY 2.8 到 SYMFONY 3.0) - “The reserved indicator ”@“ cannot start a plain scalar” — in YML file. (UPGRADE SYMFONY 2.8 TO SYMFONY 3.0) 使用Symfony 2.8进行LDAP身份验证 - LDAP Authentication with Symfony 2.8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM