Download the PHP package gac/routing without Composer

On this page you can find all versions of the php package gac/routing. 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 routing

Routing library for PHP

This library allows you to create static or dynamic routes. This library was inspired by PHP Slim framework

PHP Tests License Total Downloads

Install via composer

Manual install

Download the latest release from the Releases page.

Don't forget to add these include_once statements to your php files:

Post install

To use this library properly you will need to create a .htaccess file at the root of the project.

Example of the .htaccess file would look like this:

Note

If you've named your main file differently, replace index.php in the .htaccess file with whatever your main application file is.

Quick start

Sample code to allow you to quickly start with your development.

Examples

Dynamic routes example

Chained routes

When using chained methods either use ->save() or ->add() as the last method to indicate the end of a chain

NOTE

Chained routes with save at the end

Chained routes with multiple chains in one call

Passing arguments to middleware methods

When working with middlewares you can also pass them arguments if you need to

Every middleware function can also accept an argument of type Gac\Routing\Request at any position as long as it has the proper type specified.

Optional parameters

When calling this endpoint with /demo it will output ID: defaultValue and with /demo/123 it will output ID: 123

Dependency injection on route classes

When using classes to handle your route callback, and those classes have some dependencies that need to be injected through a constructor, you can specify them as an array of arguments to be injected or let the library try to auto-inject classes.

You can also use named arguments or mix and match them

Letting the library auto-inject classes into the constructor

NOTE

The library will always try to auto-inject classes (will skip ones with null as default value) if non are provided, and you're using a class for callbacks.

Use __invoke instead for single method classes

You can also use __invoke with dependency injection as well:

For more examples look in the sample folder index.php file

Documentation

Source code documentation can be found at PHP Routing documentation page

Features


All versions of routing with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
ext-mbstring Version *
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 gac/routing contains the following files

Loading the files please wait ....