Download the PHP package illuminatech/model-route without Composer

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

Real Laravel Model Route Matching


This extension allows continuing route matching in case bound model does not exist.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

Usage

This extension allows continuing route matching in case bound model does not exist.

Imagine we need to create URL structure like the one GitHub has. There are individual users and organizations, each of which has its own page responding the URL starting from their name:

Most likely, in your project users and organizations will be stored in different database tables, so the Laravel routes configuration for this case will look like following:

And the controllers code will look like following:

However, this does not work correctly. The problem is the second route ("organizations.show") will never be matched as any organization name will be compared against first route ("users.show") only, triggering 404 error on attempt to access organization's page.

This extension solves this problem via extra URL matching validator - \Illuminatech\ModelRoute\ModelRouteValidator. Being registered, it adds particular model existence as a matching condition for the routes. This allows to pass matching to the next route, in case model, bound to the current one, does not exist. The best place to register this validator will be your route service provider. For example:

Once it is set, the routes specified above will be parsed correctly. In case there is no User record matching the requested URL route 'users.show' will be considered as 'not matched' and routing will continue to 'organizations.show'.

\Illuminatech\ModelRoute\ModelRouteValidator allows setup of the route parameter binding in the similar way to the standard explicit binding. Binders are set via \Illuminatech\ModelRoute\ModelRouteValidator::setBinders() as an array, which key is the route parameter name and value is a binder specification. Each binder can be specified as:

For example:

Note: do not specify standard explicit route parameter binding for the parameter covered by \Illuminatech\ModelRoute\ModelRouteValidator::setBinders(), as it will cause extra redundant database query. Parameter binding will be setup by \Illuminatech\ModelRoute\ModelRouteValidator automatically.

Performance Tuning

Remember that you should specify routes for any static pages before you write the route with model binding. While this extension allows routes matching to continue, if binding does not exist, matching check comes with the cost of a database query. Thus in our 'GitHub' example routes to any predefined site sections like static pages, contact page or blog, should be described beforehand:

Unfortunally, you can not always control the order of all your routes definition. Some packages like Telescope, Horizon and Nova register their own routes via separated service provider. Those routes may appear to be registered after our "users.show" and "organizations.show" ones. You may manually exclude particular URL paths from the matching using \Illuminatech\ModelRoute\ModelRouteValidator::setIgnoredUrlPaths(). For example:

With such configuration parsing of the URLs starting from '/telescope', '/horizon' or '/nova' will never trigger a database query around "users.show" and "organizations.show" routes.


All versions of model-route with dependencies

PHP Build Version
Package Version
Requires illuminate/routing Version ^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.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 illuminatech/model-route contains the following files

Loading the files please wait ....