Download the PHP package umityatarkalkmaz/route without Composer

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

Route

A small router: register paths per HTTP method, then dispatch one request.

Requirements

PHP 8.2 or newer.

Installation

Usage

dispatch() returns whatever the matched handler returns — it does not print anything itself, so you decide what reaches the response.

Placeholders

:name in a path captures one segment and passes it to the handler, in the order the placeholders appear. Everything else in the path is matched literally: /api/v1.0 matches that path and not /api/v1X0.

Four names carry a built-in pattern:

Placeholder Matches
:id [0-9]+
:slug, :url [0-9a-zA-Z_-]+
:any .+, including slashes

Any other name matches one segment ([^/]+). Constrain a route's placeholders with where(), which applies to the route it follows and to nothing else:

A constraint must be a valid pattern on its own or where() throws InvalidArgumentException at registration; it is embedded as a group, so an alternation inside it cannot reach past its placeholder.

Parameter values reach the handler exactly as they appear in the request target — percent-encoding is not decoded. /users/%2e%2e arrives as the literal %2e%2e, so decode with rawurldecode() yourself, and validate after decoding rather than before. A path holding a . or .. segment is rejected: registering one throws InvalidArgumentException, and requesting one is a miss.

Groups

The prefix applies only inside the closure, and groups nest.

Controllers

The handler string is resolved against controllerNamespace, or used as a fully-qualified class name when none is set. A missing class or method throws RuntimeException rather than failing quietly.

Misses

Without handlers, dispatch() sends a 404 or 405 status and returns null. A path that matches under a different method is reported as 405, not 404, with an Allow header naming every method the path is registered under. A setMethodNotAllowedHandler() handler receives that list as its third argument and is responsible for its own headers.

The unmatched path is never printed. Echoing it back reflects attacker-controlled input into the page.

Form method spoofing

Browsers only submit GET and POST. For the rest, the override must be enabled explicitly — it is off by default, because it lets a form field decide which method the router dispatches:

With the flag on, dispatch() honours _method on a POST request for PUT, PATCH and DELETE only. With it off the field is ignored and the request dispatches as POST.

Mounting under a subdirectory

The base path is stripped from the request before matching, on a segment boundary — mounting under /shop does not turn /shopadmin into /admin — and it is stripped from an explicitly supplied path as well, so a test dispatches the same path the browser requests.

Testing your routes

dispatch() takes an optional method and path, so routes can be exercised without a web server:

License

MIT. See LICENSE.


All versions of route with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 umityatarkalkmaz/route contains the following files

Loading the files please wait ...