Download the PHP package aporat/laravel-filter-var without Composer

On this page you can find all versions of the php package aporat/laravel-filter-var. 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-filter-var

Laravel Filter Var

Latest Stable Version Downloads Codecov Laravel Version GitHub Actions Workflow Status License

A Laravel package for filtering and sanitizing request variables with a chainable, customizable filter system.

Features

Requirements

Installation

Install the package via Composer:

The service provider (FilterVarServiceProvider) is automatically registered via Laravel’s package discovery. If you’ve disabled auto-discovery, add it manually to config/app.php:

Optionally, register the facade for cleaner syntax:

Publish the configuration file to customize filters:

This copies config/filter-var.php to your Laravel config directory.

Usage

Basic Filtering

Filter and sanitize a request variable using the facade:

This:

Available Filters

Filter Description Example Input Example Output
capitalize Capitalizes words (title case) hello world Hello World
cast:<type> Casts to a type (e.g., int, string, bool) 123.45 (cast:int) 123
digit Extracts digits only abc123xyz 123
escape Escapes HTML special characters <p>Hello &</p> &lt;p&gt;Hello &amp;&lt;/p&gt;
filter_if Conditional check on array key/value ['key' => 'val'] true/false
format_date Reformats a date string 2023-01-15 15/01/2023
lowercase Converts to lowercase HELLO hello
strip_tags Removes HTML/PHP tags <b>Hello</b> Hello
trim Trims whitespace hello hello
uppercase Converts to uppercase hello HELLO
validate_email Validates email format [email protected] [email protected]
validate_url Validates URL format https://example.com https://example.com
cast_to_boolean Casts input to boolean true, false true, false
sanitize_number_int Keeps only digits abc123 123
sanitize_number_float Keeps digits and decimals abc12.3xyz 12.3
remove_whitespace Removes all whitespace a b c abc
slugify Converts string into URL-friendly slug Hello World! hello-world
normal_string Strips tags and keeps A-Z, 0-9, space, -:_. <script>alert(1)</script> alert1

Chaining Filters

Chain multiple filters using the | separator:

Custom Filters

Add custom filters by editing config/filter-var.php:

Define the custom filter class:

Use it:

Using Without Facade

Resolve from the container:

Testing

Run the test suite:

Generate coverage reports:

Contributing

Contributions are welcome! Please:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m "Add amazing feature").
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a pull request.

See CONTRIBUTING.md for details.

License

This package is open-sourced under the License File for more information.

Support


All versions of laravel-filter-var with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
illuminate/support Version ^10.0 || ^11.0 || ^12.0
nesbot/carbon Version ^2.72 || ^3.0
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 aporat/laravel-filter-var contains the following files

Loading the files please wait ....