0
votes

I want to install sonataAdminBundle on a symfony 3.2.3 project, i am documentation: http://symfony.com/doc/master/bundles/SonataAdminBundle/reference/installation.html In item 2.3.1 I create the AppExtension class:

<?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');
    }
}

I modify as described in 2.3.2 the file config.yml And when at point 2.4 I do an assets: install or caache: clear, I have the following error:

Fatal error: Class 'AppBundle\DependencyInjection\Extension' not found in T:\Wampsites\CoursSymfony\sonataBundle\src\AppBundle\DependencyInjection\AppExtension.php on line 9

It does not find the Extension class.It must miss a use, but I do not know which one. I tried with:

use Symfony\Component\DependencyInjection\Extension\Extension;

But I have the following error:

Declaration of AppBundle\DependencyInjection\AppExtension::load(array $configs, AppBundle\DependencyInjection\ContainerBuilder $container) must be compatible with Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load(array $configs, Symfony\Component\DependencyInjection\ContainerBuilder $container) in .....

Thank you for helping me solve this problem.

cordially

1

1 Answers

0
votes

Code sample in 2.3.1 that you mentioned, contains use line for Extension class:

use Symfony\Component\HttpKernel\DependencyInjection\Extension;

You're also missing another one:

use Symfony\Component\DependencyInjection\ContainerBuilder;

http://symfony.com/doc/master/bundles/SonataAdminBundle/reference/getting_started.html#have-your-bundle-load-it