Download the PHP package xinningsu/laravel-route-trailing-slash without Composer

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

Laravel route trailing slash

Let laravel route work as exactly as how we define it including the trailing slash.

Build Status Coverage Status Scrutinizer Code Quality Code Intelligence Status Quality Gate Status Reliability Rating Security Rating Maintainability

Background

Currently when we define a route, Laravel will trim all the trailing slashes, output the route url without any trailing slash. When we access an url with trailing slashes, Laravel also will trim them. That makes the trailing slashes meaningless, sometimes it's quite annoying.

Define a route like this

Output the route url

Current behavior

Expected behavior

Pagination render

Using database query builder or LengthAwarePaginator/Paginator

Current behavior

Expected behavior

Installation

There are two service providers, as the router service provider has to register at the very beginning before laravel http kernel class instantiation, so I can not make it work by Laravel Package Auto-Discovery function. Have to manually add it.

RoutingServiceProvider

open bootstrap/app.php, right after app instantiation

add

PaginationServiceProvider

Pagination Service Provider has to be added after laravel original Pagination Service Provider.

add Sulao\LRTS\Pagination\PaginationServiceProvider::class to config/app.php under providers element, after Illuminate\Pagination\PaginationServiceProvider::class

That's it, now we can generate url with/without trailing slash, same as the definition of route.

Mismatch action

Currently Laravel will trim trailing slashes of access url, so no matter how many trailing slashes the url has, it makes no difference.

Current behavior

URL Status
https://laravel.com/partners 200
https://laravel.com/partners/ 200
https://laravel.com/partners//// 200

Now we can custom the mismatch action, such as abort 404, or 301/302 redirect, if route mismatch only because of trailing slash.

404 action

open app/Providers/AppServiceProvider.php, add below line to register method

Now the behavior became

URL Status
https://laravel.com/partners 404
https://laravel.com/partners/ 200
https://laravel.com/partners//// 404

301/302 action

open app/Providers/AppServiceProvider.php, add below line to register method

Now the behavior became

URL Status
https://laravel.com/partners 301 redirect to https://laravel.com/partners/
https://laravel.com/partners/ 200
https://laravel.com/partners//// 301 redirect to https://laravel.com/partners/

License

MIT


All versions of laravel-route-trailing-slash with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
laravel/framework Version >=5.4
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 xinningsu/laravel-route-trailing-slash contains the following files

Loading the files please wait ....