A lightweight php library that let's you manipulate loading pages.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
lib
routes
.htaccess
.htaccess (view)
README.md
autoloader.php
cleverload.svg
cleverload_white.svg
composer.json
config.php
index.php
pages.php

README.md

Cleverload

A lightweight library, that takes care of your routing and file loading

Installation

How do you install?

You can use composer

composer require nytrix/cleverload

Or by manually downloading it from here.

Usage

Activate Cleverload In order to have cleverload work, you have to

.htaccess from the folder you want Cleverload to handle the request.

RewriteEngine On
RewriteRule ^(.*)$ index.php [NC,L,QSA]

Or when you use a view folder to load your files, you can also use this:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/view/%{REQUEST_URI} -f
RewriteRule (.*) /view/$1 [R=301,L]

RewriteRule ^ index.php [L]

index.php same folder as the .htaccess.

use lib\Cleverload;
use lib\Http\Request;
use lib\Routing\Router;

require_once("autoloader.php");

$request = new Request($_SERVER);
$cleverload = new Cleverload($request);
$cleverload->getRequest()->getRouter()->getResponse();

In the routes folder, you can add files or use the existing web.php file to add routes.

Routes

We support GET, POST, PUT, PATCH, DELETE, ALL request, you can route each like so

Route::get("/",function(){});
Route::post("/",function(){});
Route::put("/",function(){});
Route::patch("/",function(){});
Route::delete("/",function(){});
Route::all("/",function(){});

You can also return files instead of functions, your file comes from the viewdir, you can set this in your index.php by adding

$cleverload->viewDir("/path/to/view");

Then you can return a file from there in the routes like so:

Route::get("/","index.php");

Groups

In your router, you can also group your request, by for instance prefixes, or namespaces, or domainnames.