Download the PHP package roy404/routes without Composer

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

ROUTES - HTTP Handler

Easily manage HTTP requests in your PHP application using the roy404/routes bundle.

Installation

Install the package using Composer:


Route Feature Overview

The Route feature allows you to define and manage HTTP requests in a structured way. You can handle GET, POST, PUT, PATCH, DELETE requests, group routes, assign middleware, define controllers, and more.


Available Methods

HTTP Methods

Route Configuration


Examples

1. Group Routes

Definition
Route::group() allows you to group multiple routes under shared configuration such as middleware, prefixes, domains, or naming conventions.

This is useful for organizing routes and avoiding repetitive configuration.

`

How it works

2. Controller

Definition
Route::controller() assigns a controller class to a group of routes. All routes within the group will automatically use the specified controller.

`

How it works

3. Middleware

Definition
Route::middleware() allows you to attach one or more middleware to a route or route group. Middleware is executed before the route action and is commonly used for authentication, authorization, logging, or request validation.

Handling Unauthorized Requests
If a middleware check fails, you may define an unauthorized() handler. This callback is executed when access is denied, allowing you to customize the response (e.g., redirect, return JSON, or show an error page).

If failed, you can use unauthorized method to handle it.

Key Notes

Route-Level Middleware
Middleware can also be applied directly to a single route instead of an entire group. This is useful when only specific routes require protection or special processing.

How it works

4. Prefix

Definition
Route::prefix() adds a URI prefix to all routes inside the group. This is commonly used for admin panels, APIs, or versioned routes.

Resulting URI

How it works

5. Name

Definition
Route::name() assigns a name to a route or a group of routes. Named routes allow you to reference URLs without hardcoding paths.

Generated Route Names

How it works

6. Domain

Definition
Route::domain() restricts a group of routes to a specific domain or subdomain. This is useful for multi-tenant, admin, or API-based architectures.

How it works


Getting Started

This section walks you through setting up the routing system and defining your first routes.

1. Configure Routes

The Route::configure() method initializes the routing system. It tells the router where your project lives, which route files to load, and optionally applies global configuration such as prefixes, domains, and middleware.

Route::configure() Parameters:

Parameter Description
$root Base directory of your application (usually __DIR__)
$routes Array of route files to load (e.g. routes/web.php)
$prefix Optional global URI prefix applied to all routes
$domain Optional domain restriction for all routes
$middleware Global middleware applied to every route

Example: Global Prefix & Middleware

2. Define Routes

Routes are defined inside the route files you passed to Route::configure().

Example: routes/web.php

Using Controllers

Using Route Names

You can later reference it as:

3. How the Request Lifecycle Works

  1. Web server redirects all requests to index.php
  2. Route::configure() loads all route definitions
  3. The router matches the current request URI and HTTP method
  4. Middleware is executed (if any)
  5. The route action is executed
  6. The response is passed to the captured() callback

4. Minimal Setup Example

This is the simplest way to get your application up and running using the routing system.

Note: Make sure your web server is properly configured (Apache .htaccess or Nginx) to route all requests through a single entry file.

index.php

routes/web.php

Running the Project

You can use PHP’s built-in development server to run the application locally:

Then open your browser and visit:

You should see:

Notes


Server Configuration

Apache (.htaccess)

Nginx


All versions of routes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 roy404/routes contains the following files

Loading the files please wait ...