Download the PHP package vkovic/laravel-db-redirector without Composer

On this page you can find all versions of the php package vkovic/laravel-db-redirector. 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-db-redirector

Laravel DB redirector

Build Downloads Stable License

Manage HTTP redirections in Laravel using database

Manage redirects using database rules. Rules are intended to be very similar to Laravel default routes, so syntax is pretty easy to comprehend.


Compatibility

The package is compatible with Laravel versions 5.5, 5.6, 5.7 and 5.8 and PHP versions 7.1 and 7.2

Installation

Install the package via composer:

Database redirector middleware needs to be added to middleware array:

Run migrations to create table which will store redirect rules:

Usage: Simple Examples

Creating a redirect is easy. You just have to add db record via provided RedirectRule model. Default status code for redirections will be 301 (Moved Permanently).

You can also specify another redirection status code:

You may use route parameters just like in native Laravel routes, they'll be passed down the road - from origin to destination:

Optional parameters can also be used:

Chained redirects will also work:

We also can delete the whole chain at once (3 previous redirect records in this example):

Sometimes it's possible that you'll have more than one redirection with the same destination. So it's smart to surround code with try catch block, because exception will be raised in this case:

Usage: Advanced

What about order of rules execution when given url corresponds to multiple rules. Let's find out in this simple example:

To solve this problem, we need to agree on simple (and logical) rule prioritizing:

Priority 1: Rules without named parameters have top priority:

Priority 2: If rule origin have named parameters, those with less named parameters will have higher priority

Priority 3: If rule origin have same number of named parameters, those where named parameters are nearer the end of the rule string will have priority

So lets examine our previous case, we have:

In this case both rules have the same number of named params, but in the first rule "{param}" is nearer the end of the rule, so it will have priority and we'll end up at "/four".


Contributing

If you plan to modify this Laravel package you should run tests that comes with it. Easiest way to accomplish this would be with Docker, docker-compose and phpunit.

First, we need to initialize Docker containers:

After that, we can run tests and watch the output:


All versions of laravel-db-redirector with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
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 vkovic/laravel-db-redirector contains the following files

Loading the files please wait ....