我想在symfony 3.2.3项目上安装sonataAdminBundle,我是文档:http://symfony.com/doc/master/bundles/SonataAdminBundle/reference/installation.html 在2.3.1项中,我创建了AppExtension类:
<?php
// src/AppBundle/DependencyInjection/AppExtension.php
namespace AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\Config\FileLocator;
class AppExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
// ...
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
// ...
$loader->load('admin.yml');
}
}
我按2.3.2中的描述修改了config.yml文件 当在2.4点我做资产:安装或caache:清楚,我有以下错误:
致命错误:Class&#39; AppBundle \ DependencyInjection \ Extension&#39;在第9行的T:\ Wampsites \ CoursSymfony \ sonataBundle \ src \ AppBundle \ DependencyInjection \ AppExtension.php中找不到
它没有找到Extension类。它必须错过一个用途,但我不知道哪一个。 我尝试过:
use Symfony\Component\DependencyInjection\Extension\Extension;
但我有以下错误:
AppBundle \ DependencyInjection \ AppExtension :: load(数组$ configs,AppBundle \ DependencyInjection \ ContainerBuilder $ container)的声明必须与Symfony \ Component \ DependencyInjection \ Extension \ ExtensionInterface :: load(array $ configs,Symfony \ Component)兼容在...中的DependencyInjection \ ContainerBuilder $ container)
感谢您帮我解决这个问题。
亲切
答案 0 :(得分:0)
您提到的2.3.1中的代码示例,包含use
类的Extension
行:
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
你还错过了另一个:
use Symfony\Component\DependencyInjection\ContainerBuilder;