PHP code example of lizzyman04 / fluxor-php

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

    

lizzyman04 / fluxor-php example snippets


app/router/
├── index.php           # GET /
├── api/
│   ├── users.php       # GET /api/users
│   └── users/[id].php  # GET /api/users/123

Flow::GET()->do(function($req) {
    $id = $req->param('id');
    return Response::json(['user' => $id]);
});

View::extend('layouts/main');
View::section('content');
    <h1>Hello World</h1>
View::endSection();

class UserController extends Controller
{
    public function index() {
        return Response::json(User::all());
    }
}

Flow::use(function($req) {
    if (!$req->isAuthenticated()) {
        return redirect('/login');
    }
});

$url = base_url('api/users');
$path = base_path('storage/logs');
$debug = env('APP_DEBUG', false);
abort(404, 'Not Found');


// app/router/api/hello/index.php

use Fluxor\Flow;
use Fluxor\Response;

Flow::GET()->do(fn($req) => 
    Response::success(['message' => 'Hello, ' . $req->input('name', 'World')])
);