PHP code example of onecthree / zpheur

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

    

onecthree / zpheur example snippets


class IndexAction extends BaseAction
{
    public function __construct( Request $request, Response $response )
    {
        parent::__construct($request, $response);
    }

    #[Route\GET(dest: '/')]
    public function getIndex( Response $response ): Response
    {   
        return $response->send('Hello World');
    }
}

// In your project, all application things are located under "app" directory.
// Namespacing in path always begin with lower alphabet, like "app" and "system"
// but namespacing in PHP code always begin with upper alphabet, see "app/Http/Action/IndexAction.php":

 declare( strict_types = 1 );
namespace App\Http\Action;

class IndexAction ... {
}
// App\Http\Action will translate to directory path: "app/Http/Action"
// and the name of class controller will be the target class file: "IndexAction.php".
// So, it will 

class ...
{
    #[Route\GET(dest: '/')]
    public function getIndex( Response $response ): Response
    {   
        return $response->send('Hello World');
    }

    #[Route\POST(dest: '/')]
    public function postIndex( Response $response ): Response
    {   
        return $response->send('Hello World');
    }

    // #[Route\PUT(dest: '/')]
    // #[Route\PATCH(dest: '/')]
    // #[Route\DELETE(dest: '/')]
    // #[Route\OPTIONS(dest: '/')]
}
app/Http/Action/IndexAction.php
system/var/cache/route/source.php
bash
$ php bin/console make:route