Skip to content

rodrigo-barboza/minivel-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minivel-framework

A mini php framework inspired by Laravel developed by Rodrigo Barboza

Routing

The default route file is "web.php", currently supported request methods are only GET and POST. To add a route you can do this:

With anonymous functions

    $this->get('', function() {
        echo 'welcome. ';
    });

Where the first param is a path of route and the second param is a anonymous function. This route makes a get request and excecute the anonymous function.

With controllers

The first parameter is the route path and the second parameter is an array with the first position being the path of the controller starting from the root folder (default) "modules", and the second position is the specified controller action.

    $this->get('home', ['controllers/HomeController', 'index']);

Dynamic routing

You can do requests with dynamic routes passing params between keys:

    $this->get('home/{id}', ['controllers/HomeController', 'index']);

And you can access this value of dynamic route on the specified controller:

    public function index($data)
    {
        echo "received id by dynamic route: ". $data['id'];
    }

Additional route files

you can easily add other route files by adding inside routes and running loadRouteFile() function to add the routes to web.php:

dashboard.php

    $this->get('dashboard', function(){
        echo "dashboard";
    });

web.php

    $this->get('', function() {
        echo 'index';
    });

    $this->get('home', function() {
        echo 'home. ';
    });

    ...

    $this->loadRouteFile('dashboard');

About

A mini php framework inspired by Laravel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published