PHP code example of fyyb / express

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

    

fyyb / express example snippets




    const BASE_DIR = '/ path / to / project /';

    ...




    e __DIR__ . "/vendor/autoload.php";

    use Fyyb\Router;
    use Fyyb\Request;
    use Fyyb\Response;

    $app = Router::getInstance();

    $app->get('/', function(Request $req, Response $res) {
        $res->send('Hello World!');
    });

    $app->run();

    $app->get('/', function (Request $req, Response $res) {
        $res->send('Hello World!');
    });

    $app->post('/', function (Request $req, Response $res) {
        $res->send('Got a POST request');
    });

    $app->put('/', function (Request $req, Response $res) {
        $res->send('Got a PUT request');
    });

    $app->delete('/', function (Request $req, Response $res) {
        $res->send('Got a DELETE request');
    });

    $app->any('/user', function (Request $req, Response $res) {
        $res->send('Got a GET, POST, PUT and DELETE request at /user');
    });

    $app->map(['GET', 'POST'], '/test', function (Request $req, Response $res) {
        $res->send('Got a GET and POST request at /test');
    });

   .
   ├─ App/
   │    └── ...
   ├─ vendor/
   │    └── ...
   ├─ .htaccess
   ├─ config.php
   ├─ index.php
   └─ composer.json

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA]