Skip to content

amirkamizi/php-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

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 amirkamizi/router

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@amirkamizi.com";
});

or

function contactMe(){
    echo "contact me at info@amirkamizi.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 info@amirkamizi.com to report security vulnerabilities.

Credits

License

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages