PHP code example of kynetcode / wpzylos-http

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

    

kynetcode / wpzylos-http example snippets


use WPZylos\Framework\Http\Request;

$request = Request::capture();

// POST first, then GET
$name = $request->input('name', 'Guest');

// Sanitized helpers
$email = $request->email('email');
$page  = $request->absint('page', 1);

// Subset of input
$credentials = $request->only(['username', 'password']);

use WPZylos\Framework\Http\Response;

// JSON response
$response = Response::json(['status' => 'ok', 'user' => $name]);
$response->send();

// Redirect
Response::redirect('/dashboard')->send();

use WPZylos\Framework\Http\Pipeline;

$response = (new Pipeline($container))
    ->send($request)
    ->through([AuthMiddleware::class, LoggingMiddleware::class])
    ->then(function (Request $request) {
        return Response::json(['message' => 'Hello!']);
    });