Download the PHP package willy68/pg-router without Composer

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

pg-router

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require Coverage Status Continuous Integration

A fast, flexible, and PSR-7 compatible HTTP router for PHP applications. Built for performance with support for advanced routing patterns, middleware stacking, and route caching.

Table of Contents

Features

Credits

The regex pattern implementation and benchmarking are inspired by nikic/Fast-Route.
For a detailed explanation of how this approach works and why it is fast, please read nikic's blog post.

This router's implementation is original and may differ in speed or structure compared to Fast-Route.
Some parts do not strictly follow the same patterns as nikic/Fast-Route.

Requirements

Installation

Install via Composer:

Quick Start

Advanced Usage

Route Parameters

It is possible to define default tokens for parameters:

Optional Segments

Breaking Change: Optional segments now use a new syntax with [!...;...] pattern:

This route matches:

Parameters will be available in the request based on the provided segments.

Route Groups

Organize related routes with shared prefixes and middlewares:

Middleware

Apply middleware to individual routes or groups:

Named Routes

Generate URLs using named routes:

CRUD Helper

This creates the following routes:

URL Generation

Route Caching

Enable route caching for production environments:

Router::CONFIG_CACHE_POOL_FACTORY allows you to use a custom PSR-6 compatible cache pool implementation,
but this parameter is optional.

Using FileCache with Regex Collector

The FileCache class provides a simple file-based caching solution that works well with all regex collectors.

Here's a practical example of using FileCache with route collectors:

In this example:

  1. We create a FileCache instance pointing to a cache directory
  2. We set up all available Collectors for route collection
  3. We use fetch() which will return cached data if available, or execute the callback to generate and cache the data
  4. We measure and display the execution time to demonstrate the performance benefit of caching

The fetch() method is particularly useful as it handles both the cache check and the callback execution in one call, making your code cleaner and more efficient.

Using the returned data directly in a Matcher like:

Performance

pg-router is designed for high performance:

Testing

This project uses PHPUnit for testing. To run the tests, ensure you have PHPUnit installed via Composer:

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows PSR-12 coding standards and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author: William Lety Maintainer: willy68 Repository: pg-router


All versions of pg-router with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1 || ~8.2 || ~8.3 || ~8.4
psr/container Version ^1.0 || ^2.0
psr/http-message Version ^1.0
fig/http-message-util Version ^1.1
psr/http-server-middleware Version ^1.0
willy68/pg-middleware-stack Version ^0.1
symfony/cache Version ^7.2
psr/cache Version ^3.0
psr/simple-cache Version ^3.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 willy68/pg-router contains the following files

Loading the files please wait ...