Symfony3升级时的命名空间问题

Got*_*bel 4 namespaces upgrade symfony

我目前正在尝试将我的Symfony2应用程序升级到Symfony3.我有一个SecurityController覆盖了FOSUserBundle\SecurityController:

namespace Acme\MyBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAware;

class SecurityController extends ContainerAware
{
    // ...
}
Run Code Online (Sandbox Code Playgroud)

但我得到一个ClassNotFoundException:

尝试从命名空间"Symfony\Component\DependencyInjection"加载类"ContainerAware".
您是否忘记了另一个命名空间的"use"语句?

是否有任何我在升级说明中找不到的更改.有人能指出我的方法来解决这个问题吗?

Ale*_*ita 5

由于此PR的变化,ContainerAware已在2.8中弃用并在3.0中删除而赞成ContainerAwareTrait

  • 你可以像在这个例子中那样使用它:https://github.com/symfony/symfony/blob/582f4753a343f230fbe18b4e9a0747d48351ddfb/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundleController (2认同)