Download the PHP package royvoetman/laravel-prefixer without Composer
On this page you can find all versions of the php package royvoetman/laravel-prefixer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download royvoetman/laravel-prefixer
More information about royvoetman/laravel-prefixer
Files in royvoetman/laravel-prefixer
Package laravel-prefixer
Short Description Define a prefix in your controller which is automatically appended to your view- or route-names.
License MIT
Informations about the package laravel-prefixer
Laravel Prefixer
Introduction
This packages allows you to define a prefix in your controller which will be automatically appended to your view and/or route names.
In a resource controller, it is a common pattern to have all the associated views in the same folder, and the same goes for the location of your routes. With this feature, you can define a prefix which is automatically appended to your view-name or route-name.
Installation
View prefixes
When you want to use View prefixes your controller will have to implement the RoyVoetman\Prefixer\Contracts\ViewPrefix interface. This interface requires you to add a viewPrefix method that returns a string.
Second your Controller must include the RoyVoetman\Prefixer\Http\Traits\CreatesViews trait. This trait includes the view(string $view) method to the controller which handles the prefixing for us. The best practice is to include this trait in your BaseController . This method checks if the CreatesViews interface is implemented, if this is not the case this method will behave the same as the view() global helper function.
Route prefixes
Route prefixing works the same as View Prefixing except for the following:
The Controller must implement the RoyVoetman\Prefixer\Contracts\RoutePrefix interface and must include the RoyVoetman\Prefixer\Http\Traits\ForwardsRequests trait.
Instead of the viewPrefix method, you have to include a routePrefix method. And instead of the view(string $view) method you have to use the redirect(string $route) method. When the RoutePrefix method is not implemented this method will behave the same as calling redirect()->route($route).
Route prefixes only work if you are using named routes.
View and Route prefixes
There is a convenient shortcut when you want to implement the ViewPrefix and the RoutePrefix interface. You can include the RoyVoetman\Prefixer\Contracts\ResponsePrefixes interface which just extends both interfaces.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Contributions are welcome and will be fully credited. We accept contributions via Pull Requests on Github.
Pull Requests
- PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.
- Document any change in behaviour - Make sure the
README.mdand any other relevant documentation are kept up-to-date. - Create feature branches - Don't ask us to pull from your master branch.
- One pull request per feature - If you want to do more than one thing, send multiple pull requests.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-prefixer with dependencies
php Version ^7.2 || ^8.0
illuminate/http Version ^5.7|^6.0|^7.0|^8.0|^9.0|^10.0