Autowiring services

I have an issue when trying to autowire services. The following works fine in vanilla symfony:

        resource: '../../src/*'
        exclude: '../../src/{DependencyInjection,Entity,Migrations,Tests,AppBundle.php}'

but in Pimcore I get:

Expected to find class "AppBundle\AppBundle\AppBundle" in file "/var/www/html/src/AppBundle/AppBundle.php"

I don’t really want to declare each service manually, am I doing something wrong or does this just not work because of the way Pimcore bootstraps Symfony?

It is possible to define one service and set autowire to false only for that file. This might be a way to have autowire enabled but disable it only for specific files.
This is only applicable in your case in which the exclude might cause problems

Moin Florian,
the exclude is not the problem, the problem in my view is, that for some reason, where pimcore should look for “AppBundle\AppBundle” it is looking for “AppBundle\AppBundle\AppBundle”, see the error message above.

can you provide your AppBundle.php? Mine is empty so there is no problem.
I’d suggest taking a shot for the AppBundle.php exclusion.

I dont think the AppBundle.php is of any relevance, the issue is, that symfony/pimcore looks for AppBundle/AppBundle/AppBundle where it should be looking for AppBundle/AppBundle.

But anyways, here is my AppBundle.php:


namespace AppBundle;

use Pimcore\Extension\Bundle\AbstractPimcoreBundle;

class acAppBundle extends AbstractPimcoreBundle
    public function getJsPaths()
        return [

    public function getEditmodeJsPaths()
        return [

It must be excluded, because this file must not be autowired.

I now found out that I did this in the wrong config file, the proper file for this is: src/AppBundle/Resources/config/services.yml, I did it in app/config/services.yml

There I now have:

    # default configuration for services in *this* file
        # automatically injects dependencies in your services
        autowire: true
        # automatically registers your services as commands, event subscribers, etc.
        autoconfigure: true
        # this means you cannot fetch services directly from the container via $container->get()
        # if you need to do this, you can override this setting on individual services
        public: false


    # auto-register all controllers as services
        resource: '../../Controller'
        public: true
        tags: ['controller.service_arguments']

        resource: '../../EventSubscriber'

        resource: '../../Service'


    # auto-register all commands as services
        resource: '../../Command/*'
        tags: ['console.command']