Download the PHP package lachie4145/yaml-router without Composer

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

YamlRouter

A lightweight YAML-configured HTTP router for PHP projects.

Define your routes in a routes.yaml file and let YamlRouter handle matching, dispatching, middleware, and more — no framework required.

Requirements

Installation

After install, a routes.example.yaml file is copied to your project root as a reference.

Quick Start

By default Router::create() reads routes.yaml from the current working directory. You can pass an explicit path:

Route File Format

Each route supports:

Key Required Description
method Yes HTTP method (GET, POST, PUT, PATCH, DELETE)
path Yes URL path starting with /
response One of these Static response body
handler One of these PHP handler (see Handlers)
redirect One of these Redirect target URL
name No Named route identifier
middleware No String or list of middleware handlers
constraints No Per-parameter regex constraints
status No Override HTTP status code (default 200)
headers No Extra response headers

Handlers

Static response

Controller method

The method receives array $params where keys are the dynamic path segments:

PHP file

The file is included with $params in scope. If the file echoes output it is captured; if it returns a value that value is used as the response.

Callable function

Route Groups

Group routes under a shared prefix, namespace, and/or middleware:

The prefix is prepended to every route path in the group. The namespace is prepended to controller-style handlers that don't already contain a namespace.

Constraints

Constrain dynamic parameters to a regex pattern:

Built-in aliases:

Alias Pattern
int [0-9]+
slug [a-z0-9]+(?:-[a-z0-9]+)*
uuid [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}

Named Routes

Assign a name to a route and generate URLs from it:

Middleware

Middleware handlers use the same ClassName@method or callable string format as route handlers. A middleware that returns a non-null value short-circuits dispatch and sends that value as the response instead. Returning null allows the request to continue.

Global middleware

Runs before every request:

Group middleware

Runs for every route in the group:

Per-route middleware

Middleware runs in order: global → group → per-route.

Redirects

The default redirect status is 302. Override with status:

Custom Status & Headers

Route Caching

Pass a cache file path to avoid re-parsing the YAML on every request:

The cache is automatically invalidated when routes.yaml is modified.

Built-in Route Docs

Enable a GET /docs endpoint that renders an HTML table of all registered routes:

Disable or guard this endpoint in production.

WAF

Enable the built-in Web Application Firewall to block common attack patterns:

Custom WAF rules can be added via customRules:

PSR-7 Support

Install psr/http-message in your project and use PsrAdapter:

License

MIT


All versions of yaml-router with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
composer-plugin-api Version ^2.0
symfony/yaml Version ^7.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 lachie4145/yaml-router contains the following files

Loading the files please wait ...