1. Go to this page and download the library: Download bamiz/use-case-executor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bamiz / use-case-executor example snippets
namespace YourOrganization\YourApplication;
class MyUseCase
{
public function execute(MyUseCaseRequest $request)
{
// ...
}
}
$inputProcessorContainer = new \Bamiz\UseCaseExecutor\Container\Container();
$inputProcessorContainer->set(
\Bamiz\UseCaseExecutor\Execution\UseCaseContextResolver::DEFAULT_INPUT_PROCESSOR,
new \Bamiz\UseCaseExecutor\Processor\Input\ArrayInputProcessor()
);
$responseProcessorContainer = new \Bamiz\UseCaseExecutor\Container\Container();
$responseProcessorContainer->set(
\Bamiz\UseCaseExecutor\Execution\UseCaseContextResolver::DEFAULT_RESPONSE_PROCESSOR,
new \Bamiz\UseCaseExecutor\Processor\Response\IdentityResponseProcessor()
);
$useCaseContainer = new \Bamiz\UseCaseExecutor\Container\Container();
$useCaseContainer->set('my_use_case', new MyUseCase());
$contextResolver = new \Bamiz\UseCaseExecutor\Execution\UseCaseContextResolver(
$useCaseContainer,
$inputProcessorContainer,
$responseProcessorContainer
);
$actorRecognizer = new \Bamiz\UseCaseExecutor\Actor\CompositeActorRecognizer();
$useCaseExecutor = new \Bamiz\UseCaseExecutor\UseCaseExecutor($contextResolver, $actorRecognizer);