bamiz / use-case-executor-bundle
A Symfony Bundle that provides tools facilitating the isolation of business logic of your application from the delivery mechanisms.
Installs: 1 510
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=5.5.0
- bamiz/use-case-executor: 0.5.0
- doctrine/annotations: ^1.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/form: ~2.3|~3.0
- symfony/framework-bundle: ~2.3|~3.0
- symfony/options-resolver: ~2.3|~3.0
- symfony/serializer: ~2.3|~3.0
- symfony/templating: ~2.3|~3.0
Requires (Dev)
- phpspec/phpspec: ^3.0
This package is not auto-updated.
Last update: 2024-11-09 20:17:42 UTC
README
Use Case Executor Bundle is a Symfony bundle providing an example implementation of Screaming Architecture, with help of components that come with Symfony framework. It encourages designing your class in a fashion that reflects the intention of your application. The tools provided by Use Case Executor Bundle relieve you of the repetitive task of extracting the information required to perform the right behavior from the application input, which helps you output the results in the desired way.
Installation
Just run
$ composer require bamiz/use-case-executor-bundle
Configuration
Register your bundle in AppKernel.php:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Bamiz\UseCaseExecutorBundle\BamizUseCaseExecutorBundle(), ); // ... } // ... }
Enable serializer in app/config.yml:
# app/config.yml
framework:
serializer: ~
Basic usage
Register your Use Case as a Symfony service:
# app/services.yml
app.my_use_case:
class: AppBundle\UseCase\MyUseCase
Using an annotation, name the Use Case and optionally assign an Input Processor and a Response Processor to it.
Make sure that the Use Case class contains an execute()
method with one type-hinted parameter.
<?php // src/AppBundle/UseCase/MyUseCase.php namespace AppBundle\UseCase; use Bamiz\UseCaseExecutorBundle\Annotation\UseCase; /** * @UseCase("My Use Case", input="http", response="json") */ class MyUseCase { public function execute(MyUseCaseRequest $request) { // ... } }
Use the Use Case Executor to execute your Use Cases:
<?php // src/AppBundle/Controller/MyController.php namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; class MyController extends Controller { public function myAction(Request $request) { return $this->get('bamiz_use_case.executor')->execute('My Use Case', $request); } }
Documentation
- Concept - Use Cases, Requests, and Responses explained, basic architecture and Bundle usage examples
- Use Cases in Symfony - Differences between Application and Use Case layers explained, introducing concepts of Input and Output
- Use Case Contexts - How to configure the way your Use Cases are executed
- Toolkit - Input and Response Processors shipped with the bundle
- Using multiple Input and Response Processors
- Actors