bodawahid/php-routing

this is a routing package made by boda wahid

dev-main 2023-09-11 16:26 UTC

This package is auto-updated.

Last update: 2024-05-11 18:02:10 UTC


README

This package was developed during [PHP Course - beginned to advance]

It's a router for PHP to handle the requests.

Support us

to support me for the package or the course you can contact info@amirkamizi.com

Installation

You can install the package via composer:

composer require bodawahid/php-routing:dev-main@dev

Usage

you need to have a .htaccess file to redired everything to index or any other file.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]

then inside that file you can use the router to handle the reuqies.

passing name of that file that is going to handle the request.

Router::handle("GET","/contact","contact.php");

or

Router::get("/contact","contact.php");

Or you can pass anonymous and predefined functions to handle the request

Router::handle("GET","/contact",function(){
    echo "contact me at info@bodawahid.com";
});

or

function contactMe(){
    echo "contact me at info@bodawahid.com";
}
Router::get("/contact","contactMe");

Testing

This was for learning purposes. Not tests has been written yet.

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contribution guidelines will be written here or on a separate file like changelog. for now no contribution is accepted.

Security Vulnerabilities

Please contact me at bodawahid456@gmai;.com to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.