Download the PHP package devcoder-xyz/php-router without Composer

On this page you can find all versions of the php package devcoder-xyz/php-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 php-router

PHP Router

PHP Router is a simple and efficient routing library designed for PHP applications. It provides a straightforward way to define routes, handle HTTP requests, and generate URLs. Built with PSR-7 message implementation in mind, it seamlessly integrates with PHP applications.

Installation

You can install PHP Router via Composer. Just run:

Composer Require

Requirements

Usage

  1. Define Routes: Define routes using the Route class provided by PHP Router.

  2. Initialize Router: Initialize the Router class with the defined routes.

  3. Match Requests: Match incoming HTTP requests to defined routes.

  4. Handle Requests: Handle matched routes by executing appropriate controllers or handlers.

  5. Generate URLs: Generate URLs for named routes.

Example

Features

Route Definition

Routes can be defined using the Route class provided by PHP Router. You can specify HTTP methods, attribute constraints, and handler methods for each route.

Easier Route Definition with Static Methods

To make route definition even simpler and more intuitive, the RouteTrait provides static methods for creating different types of HTTP routes. Here's how to use them:

Method get()

Example Usage:

Method post()

Example Usage:

Method put()

Example Usage:

Method delete()

Example Usage:

With these static methods, defining routes becomes a breeze, providing a smoother and more efficient way to handle routing in your PHP application.

Using where Constraints in the Route Object

The Route object allows you to define constraints on route parameters using the where methods. These constraints validate and filter parameter values based on regular expressions. Here's how to use them:

Method whereNumber()

This method applies a numeric constraint to the specified route parameters.

Example Usage:

Method whereSlug()

This method applies a slug constraint to the specified route parameters, allowing alphanumeric characters and hyphens.

Example Usage:

Method whereAlphaNumeric()

This method applies an alphanumeric constraint to the specified route parameters.

Example Usage:

Method whereAlpha()

This method applies an alphabetic constraint to the specified route parameters.

Example Usage:

Method where()

This method allows you to define a custom constraint on a specified route parameter.

Example Usage:

By using these where methods, you can apply precise constraints on your route parameters, ensuring proper validation of input values.

Generating URLs

Generate URLs for named routes using the generateUri method.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to help improve the library.

License

This library is open-source software licensed under the MIT license.


All versions of php-router with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
psr/http-message Version ^1.0|^2.0
psr/http-server-middleware Version ^1.0
psr/http-factory Version ^1.0
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 devcoder-xyz/php-router contains the following files

Loading the files please wait ....