Php-Express-Router

Php Express Router

Php Express Router is a lightweight and flexible PHP routing library that allows you to easily handle HTTP requests and define routes for your web application.

Features

Installation

To get started using Php Express Router, follow these steps:

  1. Clone the repository or download the source code.

    git clone https://github.com/Jobians/Php-Express-Router.git
    
  2. Place the cloned files in your project directory:

    your_project/
        - core/
            - modules/
                - smarty/
            - middlewares/
                - static.php
            - Request.php
            - Response.php
            - Router.php
        server.php
        .htaccess
    

    The core/ directory contains essential router files and modules. The middlewares/ directory holds the built-in static middleware file.

Usage

Here are some usage examples to get you started:

Basic Route

require_once 'core/Router.php';

$router = new Router();

$router->get('/', function($req, $res) {
    $res->send('Hello, World!');
});

$router->run();

Configuration Setup

You can configure the router using the set method. This method allows you to customize various aspects of the router’s behavior. Here are the available configuration options:

It’s important to set these configurations before defining routes and starting the router using the run method. Configuration settings will affect the router’s behavior and how it handles requests.

More Examples

For additional usage examples, check the examples folder in this repository. You’ll find more scenarios and use cases that can help you get a deeper understanding of how to use Php Express Router effectively.

Support

If you find my work helpful, you can support me by donating:

Donate

Contributing

Contributions are welcome! If you find any issues or want to add new features, feel free to submit a pull request.

License

This project is licensed under the MIT License.