Download the PHP package pedroquezado/router without Composer

On this page you can find all versions of the php package pedroquezado/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package router

Router - PedroQuezado

Maintainer Source Code PHP from Packagist Latest Version Build Quality Score Total Downloads

About PedroQuezado

PedroQuezado/Router is a PHP router component designed for routing requests in your application or API. It provides a simple and intuitive way to define routes and handle HTTP verbs (GET, POST, PUT, PATCH, DELETE) using the MVC pattern. The router works independently, ensuring isolation and seamless integration into your projects.

Installation

You can install the PedroQuezado Router via Composer. Run the following command:

Router Class

The Router class is the main entry point for routing requests. It provides methods to define routes, handle different HTTP verbs, and run the router to match and execute the appropriate route handlers.

Usage

To use the Router class in your application, follow these steps:

Here's an example of how to use the Router class:

In the example above, we instantiate the Router class, define different routes using the get(), post(), put(), and delete() methods, and finally call the run() method to dispatch the routes.

Methods

get($path, $callback)

Defines a route for HTTP GET requests.

put($path, $callback)

Defines a route for HTTP PUT requests.

patch($path, $callback)

Defines a route for HTTP PATCH requests.

delete($path, $callback)

Defines a route for HTTP DELETE requests.

Note: The $path parameter can include placeholders enclosed in curly braces {} to capture dynamic segments of the URL. These placeholders can be accessed in the callback function or class method as parameters.

Constructor

The Router class constructor accepts the base URL as its parameter. This base URL is used for generating the correct route URLs in your application. Here's an example of creating a new Router instance:

Defining Routes

Here's an example of defining a GET route that maps to a closure function:

Class method callback:

In the class method callback format, the class and method names are separated by the double-colon (::) syntax.

Namespaces

The namespace() method allows you to define a namespace for the class or classes that will be referenced in the callbacks. This is useful for organizing classes into different directories or namespaces. Here's an example of how it can be used:

In this example, the UserController and ProductController classes are located in the App\Controllers namespace.

Middleware

middleware($callback): Define um middleware para ser executado antes de uma rota.

Group

group($options, $callback): Define um grupo de rotas para compartilhar configurações comuns.

Dispatching Routes

Once you have defined your routes, you can call the run() method to dispatch the routes and handle incoming requests.

The run() method will match the current request URL and HTTP method to the defined routes and execute the corresponding callback function or class method.

Contributing

Contributions are welcome! If you would like to contribute to the PedroQuezado Router, feel free to open an issue or submit a pull request. We appreciate your feedback and contributions to make this project even better.

License This project is licensed under the MIT License.


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pedroquezado/router contains the following files

Loading the files please wait ....