joselfonseca / laravel-tactician Goto Github PK
View Code? Open in Web Editor NEWLaravel Tactician is an implementation of the Command Bus Tactician by Ross Tuck.
License: MIT License
Laravel Tactician is an implementation of the Command Bus Tactician by Ross Tuck.
License: MIT License
Hey,
Your service provider hasn't the publishes
method. It requires this method in order to run php artisan vendor:publish
without problems.
{
"error": {
"type": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message": "Call to undefined method Joselfonseca\\LaravelTactician\\Providers\\LaravelTacticianServiceProvider::publishes()",
"file": "/project/vendor/joselfonseca/laravel-tactician/src/Providers/LaravelTacticianServiceProvider.php",
"line": 63
}
}
Profile:
Laravel 4
joselfonseca/laravel-tactician 0.3.2
php artisan make:tactician /src/Commands/CommandName
creates the files in /app/CommandBus
whereas I have clearly specified a root path.
/app/CommandBus/Commands/CommandNameCommand
/app/CommandBus/Handlers/CommandNameHandler
at leaset
/src/Commands/Commands/CommandNameCommand
/src/Commands/Handlers/CommandNameHandler
OR
/src/Commands/CommandNameCommand
/src/Commands/CommandNameHandler
Also, It would be nicer if there were a flag like --bare
to skip creating Commands
and 'Handlers' folders.
Following test fails in PHP 8.0.2 but passes in PHP 7.2.8
It throws exception when locator from laravel container is not found
for both LaravelLocator and LaravelLazyLocator with next error:
Failed asserting that exception of type "ErrorException" matches expected exception "League\Tactician\Exception\MissingHandlerException". Message was: "Undefined index: TestCommand"
I am working on a patch
$ vendor/bin/phpunit -v
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.33 with Xdebug 2.5.5
Configuration: C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\phpunit.xml
......EEEEEEE.............
Time: 55.66 seconds, Memory: 11.25MB
There were 7 errors:
1) Joselfonseca\LaravelTactician\Tests\Generators\TestGenerators::test_it_creates_command
ErrorException: The Symfony\Component\Process\ProcessUtils::escapeArgument() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use a command line array or give env vars to the Process::start/run() method instead.
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\symfony\process\ProcessUtils.php:43
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Queue\Listener.php:87
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Queue\Listener.php:75
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Queue\Listener.php:63
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Queue\QueueServiceProvider.php:185
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:726
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:608
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:575
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:728
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:1172
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Foundation\Providers\ArtisanServiceProvider.php:596
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:726
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:608
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Container\Container.php:575
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:728
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Console\Application.php:192
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Console\Application.php:206
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:232
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Console\Application.php:111
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Console\Application.php:58
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:284
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:220
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:221
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\tests\Generators\TestGenerators.php:56
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\tests\Generators\TestGenerators.php:56
C:\Users\Usuario\GitHub\jagarsoft\laravel-tactician\tests\Generators\TestGenerators.php:88
Such as logging? Thanks!
I kind of assumed it would make sense to create a new ServiceProvider for having all the Command / Handler bindings in one place in the app. I'm using the ::register()
-method to set this up.
I saw that the LocatorInterface
has an ::addHandlers(array $commandClassToHandlerMap)
-method, so in the ::register()
-method of the service provider, I type hint for the LocatorInterface
, so I can call the ::addHandlers
-method.
Excerpt:
/**
* Bootstrap the application services. Boot happens after all providers have
* registered. So all bindings have been made and can be used.
*
* @return void
*/
public function boot(LocatorInterface $handlerLocator)
{
$handlerLocator->addHandlers([
GeneratePlayerCommand::class => GeneratePlayerHandler::class,
]);
}
However this does not work. This does not work because for each resolve the IoC container does, it returns a new instance. I.e. the LaravelTacticianServiceProvider::register()
method uses $this->app->bind()
and not $this->app->singleton()
. For the LocatorInterface
, MethodNameInflector
, CommandNameExtractor
and CommandBusInterface
I think it makes sense to use the singleton()
method, since the same instance should be able to be reused during the request.
Or maybe I am missing a reason why that should not be the case? If I am not missing anything, I could make a PR for this?
Hi folks
What do you think about implementing Undo feature?
Comments will be welcomed!
I have started working on it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.