PHP code example of netglue / expressive-prg

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

    

netglue / expressive-prg example snippets


// use NetglueExpressive\Middleware\PostRedirectGet;

'dependencies' => [
    'invokables' => [
        PostRedirectGet::class => PostRedirectGet::class
    ],
],
    
'routes' => [
    'some-form' => [
        'name' => 'some-form',
        'path' => '/somewhere',
        'allowed_methods' => ['GET', 'POST'],
        'middleware' => [
            PostRedirectGet::class
            // Your middleware to post process, render templates etc…
        ],
    ],
],

$post = $request->getAttribute('prg');
if (false === $post) {
    // No POST has occurred, probably render the form template
}

// Otherwise, process POST data, validate, store, whatever…