PHP code example of bamiz / use-case-executor-bundle

1. Go to this page and download the library: Download bamiz/use-case-executor-bundle 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-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Bamiz\UseCaseExecutorBundle\BamizUseCaseExecutorBundle(),
        );

        // ...
    }

    // ...
}


// 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)
    {
        // ...
    }
}


// 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);
    }
}