PHPackages                             spatial/route - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. spatial/route

ActiveLibrary[API Development](/categories/api)

spatial/route
=============

PHP routing which contains Authorization, CORS, nexted routes

v1.0.2(6y ago)134MITPHPPHP ^7.4

Since Nov 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/aiira-co/spatial-route)[ Packagist](https://packagist.org/packages/spatial/route)[ RSS](/packages/spatial-route/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Spatial Route - Robost request router for PHP
=============================================

[](#spatial-route---robost-request-router-for-php)

Set defaultContentType(), enableCache(), allowedMethods(), controllerNamespaceMap(), and authGuard() to list Authorization(CanActivate Interface) Objects

Routing is responsible for mapping request URIs to endpoint selectors and dispatching incoming requests to endpoints. Routes are defined in the app and configured when the app starts. A route can optionally extract values from the URL contained in the request, and these values can then be used for request processing. Using route information from the app, routing is also able to generate URLs that map to endpoint selectors.

Install
-------

[](#install)

You should install [Route with Composer](https://getcomposer.org):

```
composer require spatial/route
```

Requires PHP 7.4 or newer.

Routing Basic
-------------

[](#routing-basic)

Most apps should choose a basic and descriptive routing scheme so that URLs are readable and meaningful. The default conventional route {controller=Home}/{action=Index}/{id?}:

Supports a basic and descriptive routing scheme. Is a useful starting point for UI-based apps. Developers commonly add additional terse routes to high-traffic areas of an app in specialized situations (for example, blog and ecommerce endpoints) using attribute routing or dedicated conventional routes.

Web APIs should use attribute routing to model the app's functionality as a set of resources where operations are represented by HTTP verbs. This means that many operations (for example, GET, POST) on the same logical resource will use the same URL. Attribute routing provides a level of control that's needed to carefully design an API's public endpoint layout.

Usage
-----

[](#usage)

In Spatial Web API, a controller is a class that handles HTTP requests. The public methods of the controller are called `action` `methods` or simply `actions`. When the Web API framework receives a request, it routes the request to an action.

To determine which action to invoke, the framework uses a routing table.

```
