PHP code example of wdalmut / frankie

1. Go to this page and download the library: Download wdalmut/frankie 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/ */

    

wdalmut / frankie example snippets



/**
 * @Before(targetClass="HttpAuth", targetMethod="basic")
 * @After(targetClass="Serializer", targetMethod="toJson")
 */
class MyController
{
    /**
     * @Inject
     * @var Zend\EventManager\EventManager
     */
    private $eventManager;

    /**
     * @Route("/my/path/{id}", methods={"GET"})
     * @Before(targetClass="MyHook\ThisOne", targetMethod="count")
     * @Before(targetClass="Stopwatch", targetMethod="start")
     * @After(targetClass="Stopwatch", targetMethod="stop")
     */
    public function get(Request $request, Response $response, $id)
    {
        // ...
        $this->eventManager->trigger("mark-it", $element);
        // ...
    }
}




namespace spec;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Zend\EventManager\EventManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class MyControllerSpec extends ObjectBehavior
{
    function let(EventManager $em)
    {
        $this->setEventManager($em);
    }

    function it_is_initializable()
    {
        $this->shouldHaveType('MyController');
    }

    function it_should_trigger_the_mark_event(
        Request $request, Response $response, EventManager $em
    )
    {
        $em->trigger("mark-it", Argument::Any())->shouldBeCalledTimes(1);

        $this->get($request, $response);
    }
}