PHP code example of agorlov / lipid

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

    

agorlov / lipid example snippets



class ActIndex implements Action
{
    public function handle(Response $resp): Response
    {
        return $resp->withBody(
            "Hello, World 2!<br>" . 
            '<a href="/login">login</a>'
        );
    }
}


class ActIndex implements Action
{
    private $rqGet;
     
    public function __construct(array $GET = null)
    {
        $this->rqGet = $GET ?? $_GET;
    }

    public function handle(Response $resp): Response
    {
        $test = $this->GET['test'] ?? 'nothing';

        return $resp->withBody(
            "Hello, World 2!<br>" . 
            '<a href="/login">login</a>' .
            '$_GET[test]=' . htmlentities($test)
        );
    }
}


public function __construct(
    array $GET = null, 
    AppPDO $db = null, 
    Config $config = null, 
    Request $env = null,
    Session $sess = null,
    Tpl $tpl
    // or anything you need for your Action
) 
{
    $this->POST = $GET ?? $_POST;
    $this->GET = $GET ?? $_GET;
    $this->db = $db ?? new AppPDO;
    $this->config = $config ?? new CfgFile;
    $this->env = $env ?? new RqENV;
    $this->tpl = $tpl ?? new AppTpl
}

$ php -S localhost:8000 index.php