Autowiring services

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

    AppBundle\:
        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.

Moin,
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:

<?php

namespace AppBundle;

use Pimcore\Extension\Bundle\AbstractPimcoreBundle;

class acAppBundle extends AbstractPimcoreBundle
{
    public function getJsPaths()
    {
        return [
            '/bundles/app/js/pimcore/element/selector/asset.js',
            '/bundles/app/js/pimcore/document/edit.js',
        ];
    }

    public function getEditmodeJsPaths()
    {
        return [
            '/bundles/app/js/pimcore/document/tag.js',
            '/bundles/app/js/pimcore/document/tags/input.js',
            '/bundles/app/js/pimcore/document/tags/image.js',
            '/bundles/app/js/pimcore/document/tags/video.js',
            '/bundles/app/js/pimcore/document/tags/link.js',
        ];
    }
}

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:

services:
    # default configuration for services in *this* file
    _defaults:
        # 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

    #
    # CONTROLLERS
    #

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

    AppBundle\EventSubscriber\:
        resource: '../../EventSubscriber'

    AppBundle\Service\:
        resource: '../../Service'

    #
    # COMMANDS
    #

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