PHP code example of geggleto / helper_classes

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

    

geggleto / helper_classes example snippets


use \Your\Namespace;

class HelloWorldAction extends Geggleto\Helper\BaseAction {

    public function __construct(ContainerInterface $containerInterface)
    {
        parent::__construct($containerInterface);
    }
    
    public function __invoke (ServerRequestInterface $request, ResponseInterface $response, array $args) {
        $response = $this->view->render($response, "myview.twig", $args); //this will fetch from the container
        return $response;
    
    }

}


class HelloWorldMiddleware extends Geggleto\Helper\BaseMiddleware {

    public function __construct(ContainerInterface $containerInterface)
    {
        parent::__construct($containerInterface);
    }
    
    public function __invoke (ServerRequestInterface $request, ResponseInterface $response, callable $next) {
    
        //Do stuff before your Action
           
        $response = $next($request, $response);
        
        //Do Stuff After Your Action
        
        return $response;
    }

}