PHP code example of healthengine / popeye

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

    

healthengine / popeye example snippets




use Popeye\HasMiddleware;
use Popeye\Lockable;

class SpecificMiddleware
{
    use HasMiddleware;

    public function __invoke(CertainType $input)
    {
        return $this->runStack($input);
    }

    public function add(CertainHandler $handler)
    {
        return $this->addHandler([$handler, 'handle']);
    }
}

interface CertainType
{
    public function getFoo();
    public function getBar();
}

interface CertainHandler
{
    public function handle(CertainType $input);
}



use Popeye\HasMiddleware;
use Popeye\Lockable;

class ContainerAwareMiddleware
{
    // use Lockable; // add this if you want to restrict middleware modifications once its being resolved.
    use HasMiddleware;

    public function add(string $handler)
    {
        return $this->addHandler($handler);
    }

    public function resolve()
    {
        return $this->runStack($input);
    }

    /**
     * Override the trait method to use the Laravel DI container to call the handler.
     */
    protected function callHandler($handler)
    {
        // have laravel construct and call the handler
        app()->call($handler);
    }
}