4G LTE abandonment Camera Intel drones Chrome apps college Consumption assertion continuous integration distanced from Drone attack economics Market economics mobile internet Payment sensitive Shipping delivery smartphone Smartphone infringements Steam Gentoo gaming Target machinery Telecommunications behavior TLS demand Urgent UI and UX failure call

Slim PHP HTML form controller containerized PSR trait

It's not an easy task to integrate multiple clients needs into a one perspective. However, HTML forms facilitated HTTP API consumption, bringing in forwarded JS non requiring frontend, is a PHP trait convenient to use inheritance.

Consider the trait:

<?php

/**
 * HTML controller area
 * 
 * PHP version 7
 * 
 * @category HTML_Form_Response
 * @package  HTTP_Forms
 * @author   Povilas Brilius <pbrilius@gmail.com>
 * @license  eupl-1.1 https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository
 * @version  GIT: f59e387d663daeb44565e48af765918ed48ccda8
 * @link     pbgroup.wordpress.com
 */
namespace PBG\Controller\Form;

use Psr\Container\ContainerInterface;

/**
 * Form PSR container trait
 * 
 * PHP version 7
 * 
 * @category HTML_Form_Controller
 * @package  HTTP_Constructor
 * @author   Povilas Brilius <pbrilius@gmail.com>
 * @license  eupl-1.1 https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository
 * @version  Release: 1.0.0
 * @link     pbgroup.wordpress.com
 */
trait ContainerTrait
{
    /**
     * Container DI
     *
     * @var ContainerInterface
     */
    private $_container;

    /**
     * Controller constructor
     *
     * @param ContainerInterface $container DI Container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->_container = $container;
    }
}

It is used in HTML form controller, designating operations of constructor, containerizing the application HTTP formed documents, presented to the end user via UI and UX. Next, see the controller, using this trait:

/**
 * Form User controller
 * 
 * PHP version 7
 * 
 * @category HTML_Form_Controller
 * @package  HTTP_User
 * @author   Povilas Brilius <pbrilius@gmail.com>
 * @license  eupl-1.1 https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository
 * @version  Release: 1.0.0
 * @link     pbgroup.wordpress.com
 */
class User implements ControllerInterface
{
    use ContainerTrait;
}

It’s an easy way to work with multiple controllers, responding in HTML format. Nothing too special, just a handy set of tools to implement latest PSR compliant containerized methods, including OAuth 2.0 settlement.

%d bloggers like this: