PHP code example of next / simple

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

    

next / simple example snippets


php bin/cli-server.php           // 内置服务
php bin/swoole.php               // swoole
php bin/workerman.php            // workerman

$router->middleware(new SessionMiddleware(), new VerifyCSRFToken())
   ->group(function (Router $router) {
       $router->get('/', [new IndexController(), 'index']);
       $router->get('openapi', [new IndexController(), 'opanapi']);
   });



namespace App\Controllers;

use App\Http\Response;use Next\Routing\Attribute\Controller;use Next\Routing\Attribute\GetMapping;use Psr\Http\Message\ResponseInterface;use Psr\Http\Message\ServerRequestInterface;

#[Controller(prefix: '/')]
class IndexController
{
    #[GetMapping(path: '/')]
    public function index(ServerRequestInterface $request): ResponseInterface
    {
        return Response::HTML('Hello, ' . $request->query('name', 'nextphp!'));
    }
}


PHP  ^8.2