Download the PHP package sinemacula/laravel-route-linter without Composer

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

Laravel Route Linter

[![Latest Stable Version](https://img.shields.io/packagist/v/sinemacula/laravel-route-linter.svg)](https://packagist.org/packages/sinemacula/laravel-route-linter) [![PHP Version](https://img.shields.io/packagist/dependency-v/sinemacula/laravel-route-linter/php.svg)](https://packagist.org/packages/sinemacula/laravel-route-linter) [![Laravel Version](https://img.shields.io/packagist/dependency-v/sinemacula/laravel-route-linter/laravel/framework.svg?label=laravel)](https://packagist.org/packages/sinemacula/laravel-route-linter) [![Build Status](https://github.com/sinemacula/laravel-route-linter/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-route-linter/actions/workflows/tests.yml) [![Quality Gates](https://github.com/sinemacula/laravel-route-linter/actions/workflows/quality-gates.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-route-linter/actions/workflows/quality-gates.yml) [![Maintainability](https://qlty.sh/gh/sinemacula/projects/laravel-route-linter/maintainability.svg)](https://qlty.sh/gh/sinemacula/projects/laravel-route-linter) [![Code Coverage](https://qlty.sh/gh/sinemacula/projects/laravel-route-linter/coverage.svg)](https://qlty.sh/gh/sinemacula/projects/laravel-route-linter) [![Total Downloads](https://img.shields.io/packagist/dt/sinemacula/laravel-route-linter.svg)](https://packagist.org/packages/sinemacula/laravel-route-linter) [![License](https://img.shields.io/github/license/sinemacula/laravel-route-linter.svg)](LICENSE)

An Artisan command that lints a Laravel application's route table against a fixed set of RESTful URL conventions and route-integrity checks. It exits non-zero on error-severity violations, so CI can gate on it. It checks only the mechanically-checkable subset of the conventions; passing it does not prove an API is RESTful.

How It Works

The rules run against framework-free value objects behind a small set of ports, so they carry no Laravel dependency. One run:

  1. Sources the app-owned routes from the router, excluding vendor routes (the set route:list --except-vendor reports).
  2. Normalises each route: its URI split into segments, parameter names, HTTP methods, controller handler and gathered middleware.
  3. Inspects every route with the per-route rules, then runs the cross-route (aggregate) rules over the whole set. Each violation is tagged error or warning.
  4. Suppresses violations covered by an inline waiver or a config allowlist entry.
  5. Reports the findings in a fixed order and exits non-zero when any error survives.

A malformed config value - a non-array where an array is expected, a non-string word or hint, an exemption without a reason - raises an InvalidConfigurationException instead of silently weakening the verdict.

Rules

Rule Severity Checks
R1 error No action verb in a path segment (incl. compound / pluralised), with a RESTful-rewrite hint
R2 error Segments are kebab-case
R3 error Segments are lowercase
R4 error Collection segments are plural (honours configured uncountables; singletons are exempt)
R5 error No trailing or duplicate slashes
R6 error No duplicate route name (would break route() URL generation)
R7 error Standard HTTP methods only
R8 warning Named routes follow {resource}.{action}
R9 warning No HTML-only create / edit action as the final literal segment
R10 warning Routes matching a configured pattern declare the required middleware
R11 warning Resource nesting no deeper than the configured number of collection levels (default three)
R12 error Route handler (controller class / method) exists

Rule IDs are stable across releases, so waivers that name a rule stay valid on upgrade.

Installation

The service provider is auto-discovered. Publish the config to tune it:

Usage

Exits non-zero when any error-severity violation is present or the config is invalid. Warnings are reported but do not fail the run.

Waiving a Violation

Every waiver needs a written reason and can be scoped to specific rules. Waivers that suppress nothing, and allowlist entries that match no live route, are reported as stale entries. Stale entries are reported but do not fail the run.

Inline, at the route:

The waiver is stored in the route action, so it survives route:cache.

Config allowlist, for routes you cannot annotate:

match is an exact route name or an fnmatch pattern matched against the URI.

Tuning

Listing a word in verb_allowlist removes it from the verb denylist without redefining the curated list. It is rule tuning, not a per-route waiver: use it for domain nouns that share a verb's spelling (e.g. a password-resets or transfers resource). It applies to every route and needs no reason. A published verb_denylist replaces the shipped list wholesale, so leave it out of your published config to keep receiving the package's additions. The maximum nesting depth enforced by R11 is set with nesting_max_depth (default 3); only segments that name a collection count, so namespace prefixes such as auth/ or admin/ add no depth.

Singleton resources (Route::singleton() / Route::apiSingleton()) are singular by design, so R4 and R11 skip their segment. Their show, update and destroy routes are recognised automatically; list the resource path in singleton_resources (e.g. 'profile' or 'connections/{connection}/callback') to cover the rest, such as a creatable singleton's store route.

R10 (required middleware) is opt-in and ships empty. Map an fnmatch URI pattern to the middleware a matching route must declare; matching is an exact token comparison, so write parameterised middleware in full:

Extending

The rules key lists the rules the engine runs, in order. Each is a class implementing the Rule contract, resolved from the container so it may declare constructor dependencies. Remove a built-in rule by deleting its line, or append your own:

A custom rule receives the normalised route - its segments, brace-stripped parameter names, controller handler (Class@method, or null for closures) and gathered middleware - with the active config, and returns zero or more violations:

For checks that span the whole route table, such as duplicate detection, implement AggregateRule instead. Its inspect(array $routes, RuleConfig $config) receives every normalised route at once and runs after the per-route rules. List it in the same rules key. Attribute each violation to the offending route's identity() so waivers still apply.

Rule IDs must be unique across both kinds; a duplicate raises an InvalidConfigurationException when the engine is built. To change the output, for example to emit JSON or SARIF, bind your own LintReporter implementation.

Determinism

The same route definitions and config give the same output on every run, whether or not routes are cached. A cached table has lost what the rules depend on: closures are serialised and unnamed routes carry random generated names. So while routes are cached, route:lint re-runs itself in a child process with the route cache bypassed. The child boots as a fresh php artisan would, with the same process environment and any --env you pass. The cache file is never read or modified.

Requirements

Testing

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

Security

Report vulnerabilities privately; see SECURITY.md.

License

Licensed under the Apache License, Version 2.0.


All versions of laravel-route-linter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/console Version *
illuminate/routing Version *
illuminate/support Version ^12.9 || ^13.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 sinemacula/laravel-route-linter contains the following files

Loading the files please wait ...