Download the PHP package rudra/router without Composer

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

PHPunit Maintainability CodeFactor Coverage Status


Rudra-Router

A lightweight and transparent HTTP router for PHP. Supports dynamic parameters, regular expressions, optional URL segments, middleware, and RESTful resources.

Features

Installation

Basic Usage

Initialization

Facade Usage

Route Definition

Simple Routes with Closure

With Regular Expressions

Controller Method Call

Via Facade

Attribute-based Routing

The most concise way to define routes — declare them directly on controller methods using PHP 8 attributes. Routes are discovered automatically via annotationCollector().

Basic Attribute Route

Optional URL Segments

Use square brackets [...] to mark segments as optional. Nested brackets are supported for deeply optional paths.

This single attribute expands into 4 separate routes at cache-build time:

# Expanded URL
1 admin
2 admin/item
3 admin/item/page
4 admin/item/page/:page

Note: Expansion happens once during cache generation. At runtime the router works with flat strings — zero performance overhead.

Multiple URLs per Route

Pass an array of URLs to register several routes for a single method:

Combining Arrays and Optional Segments

Both features compose naturally — each element of the array is expanded independently:

This produces 8 routes (4 for admin/* + 4 for manager/*).

Regex Parameters Inside Routes

Regular expressions can be used freely — the bracket syntax for optional segments does not interfere with regex character classes:

Attributes with Middleware

Combine #[Routing] and #[Middleware] on the same method:

Preserving Route Parameters

All route parameters are preserved across expanded routes:

HTTP Methods

Any Method (GET|POST|PUT|PATCH|DELETE)

Middleware

Middleware runs before (before) and after (after) the controller. Each middleware must implement the __invoke() method.

Basic Setup

Middleware with Parameters

Middleware Example

Simple middleware without chain:

RESTful Resources

Registers standard CRUD routes with explicit plural and singular URL patterns. No magic pluralization — you define exactly what the URLs look like.

This creates the following routes:

Method URL Controller Method Description
GET api/users index List all users
GET api/user/:id read Get single user
POST api/users create Create new user
PUT api/user/:id update Full update user
PATCH api/user/:id update Partial update user
DELETE api/user/:id delete Delete user

The default action names are [index, read, create, update, delete].

Custom Method Names

You can override the default action names by passing a custom array of 5 methods:

The array order is fixed: [index, read, create, update, delete].

The set() Method — Extended Syntax

Allows defining a route with multiple HTTP methods via |:

Controller Lifecycle

When a controller method is invoked, the following stages are executed:

  1. shipInit() — base component initialization
  2. containerInit() — container initialization
  3. init() — user-defined initialization
  4. before() — hook before middleware
  5. before middleware
  6. Action method call (with automatic dependency injection)
  7. after middleware
  8. after() — hook after middleware

Automatic Dependency Injection

Action method parameters are automatically resolved via the IoC container:

Method Spoofing

For forms that do not support PUT/PATCH/DELETE, use the _method parameter:

The router automatically recognizes this as a PUT request.

Error Handling

License

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0) — a free, open-source license that:

📄 Full license text: LICENSE
🌐 Official MPL-2.0 page: https://mozilla.org/MPL/2.0/


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
rudra/annotation Version self.version
rudra/container Version self.version
rudra/exception Version self.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 rudra/router contains the following files

Loading the files please wait ...