endeavors / components-routing
The Endeavors Components Routing package
Requires
- endeavors/support-vo: ^2.0
- illuminate/events: ~5.2
- illuminate/routing: ~5.2
- illuminate/support: ~5.2
- nesbot/carbon: ~1.20
Requires (Dev)
- mockery/mockery: ~0.9
- orchestra/testbench: 3.2.x
- phpunit/phpunit: ~5
This package is not auto-updated.
Last update: 2024-11-21 23:57:14 UTC
README
This library enables the ability to use some of the new routing features only available in newer versions of the laravel framework such as signed urls (available starting in Laravel 5.6).
Require this package in your composer.json and update composer.
composer require endeavors/components-routing
Installation
After updating composer, add the ServiceProvider to the providers array in config/app.php
Endeavors\Components\Routing\FoundationServiceProvider::class,
Creating a signed route
You can create a signed route using the URL Facade.
URL::signedRoute('foo', ['id' => 1, 'username' => 'bob']);
For convenience, a helper can be used.
signed_route('foo', ['id' => 1]);
Validation
Validation of the signature is performed on the entire url.
use Illuminate\Support\Facades\Request; public function verifyEmail() { if (Request::hasValidSignature()) { // verify the email } }
You may also check if the request is invalid.
use Illuminate\Support\Facades\Request; public function verifyEmail() { if (Request::hasInvalidSignature()) { // DON'T verify the email } }
Validation can be performed only if specific parameters exist.
use Illuminate\Support\Facades\Request; public function verifyEmail() { // validate the signature if the email parameter exists if (Request::hasValidParameterSignature(['email'])) { // verify the email } }
Again, you may check if the request has an invalid signature.
use Illuminate\Support\Facades\Request; public function verifyEmail() { // validate the signature if the email parameter exists if (Request::hasInvalidParameterSignature(['email'])) { // DON'T verify the email } }