thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

Default command bus is not service Symfony 4.3 #113

Closed Pablossoo closed 4 years ago

Pablossoo commented 5 years ago

Hello, I was Installed your bundle, but I have problem with run command bus.. I Using autowiring, and this bundle throw me

$commandBus" of method "__construct()" references class "League\Tactician\CommandBus" but no such service exists. i

How do fix it>?

p4veI commented 5 years ago

Have you registered the service? Can xou share some of your implementation?

Pablossoo commented 5 years ago

No, I don't registered it as service because I found in documentation, information, that if we using autowire we dont have to nothing do.

my constructor in controller

    /**
     * BookController constructor.
     * @param UsersProjection $userProjection
     * @param UsersRepository $userRepository
     */
    public function __construct(CommandBus $tacticna,UsersProjection $userProjection, UsersRepository $userRepository)
    {
        $this->userProjection = $userProjection;
        $this->userRepository = $userRepository;
        $this->tac = $tacticna;
    }
p4veI commented 5 years ago

And have you added the bundle to the bundles.php bundle registration file ?

Pablossoo commented 5 years ago

Oh, now working, but why I have to register in bundles.php.. if symfony has flex ?

from doc

In a default Symfony application that uses Symfony Flex, bundles are enabled/disabled automatically for you when installing/removing them, so you don't need to look at or edit this bundles.php file.

p4veI commented 5 years ago

Have you been updating from older version of symfony? Maybe you don’t have flex configured properly, check out https://symfony.com/doc/current/setup/flex.html . Perhaps your index file isn’t updated etc.

Pablossoo commented 5 years ago

Ok, I fixed it.

I have one more question. How I can automatically mapping command to handler witchout declare in service.yml each handler? I can't find solution to auto mapping.

p4veI commented 5 years ago

@pablosso we’re using DI fileLoader and Definition to automatically register services as non public, with autoconfiguration and autowiring enabled. You could probably also make use of the automatic service loading with resource within your config file.

Pablossoo commented 5 years ago

I Should using HandlerMapping interface? Can you show me any example?

rosstuck commented 4 years ago

Closed due to inactivity.