aporat / laravel-filter-var
Laravel package for filtering and sanitizing request variables
Fund package maintenance!
aporat
Requires
- php: ^7.2.5
- ext-json: *
- illuminate/support: ~7.0
- illuminate/validation: ~7.0
- nesbot/carbon: ~1.0|~2.0
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-06 01:12:53 UTC
README
Laravel package for filtering and sanitizing request variables
Installation
The filter-var service provider can be installed via Composer.
composer require aporat/laravel-filter-var
To use the FilterVar service provider, you must register the provider when bootstrapping your application.
Laravel
Laravel 5.5 and above
The package will automatically register provider and facade.
Laravel 5.4 and below
Add Aporat\FilterVar\Laravell\FilterVarServiceProvider
to the providers
section of your config/app.php
:
'providers' => [ // ... Aporat\FilterVar\Laravel\FilterVarServiceProvider::class, ];
Add FilterVar facade to the aliases
section of your config/app.php
:
'aliases' => [ // ... 'FilterVar' => Aporat\FilterVar\Laravel\Facade\FilterVar::class, ];
Or use the facade class directly:
use Aporat\FilterVar\Laravel\Facade\FilterVar;
Now run php artisan vendor:publish
to publish config/filter-var.php
file in your config directory.
Lumen
Register the Aporat\FilterVar\Laravel\FilterVarServiceProvider
in your bootstrap/app.php
:
$app->register(Aporat\FilterVar\Laravel\FilterVarServiceProvider::class);
Copy the filter-var.php
config file in to your project:
mkdir config
cp vendor/aporat/laravel-filter-var/Config/filter-var.php config/filter-var.php
Configuration
In the config file you can set custom filters
Usage
Filter and escape user agent header:
$user_agent = FilterVar::filterValue('cast:string|trim|strip_tags|escape', $request->header('User-Agent'));
Credits
License
The MIT License (MIT). Please see License File for more information.