Download the PHP package webdevjohn/filterable without Composer

On this page you can find all versions of the php package webdevjohn/filterable. 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 filterable

Filterable - elegant filtering of Eloquent models.

Introduction

The Filterable package was created to provide an easy way to filter Laravel Eloquent models.

Purpose

How to works

The package uses a factory to determine which filters to apply to a model. The factory accepts one argument through the constructor, a filter component. The filter component is used to instruct the Filter Factory on which filters to instantiate. This approach allows you to have many different instances of a Filter Factory using different components that change its behaviour.

The request input is used to build the filters for a particular model. For example, the query string parameter "year_released" will instantiate the "YearReleasedFilter" class and apply the filter to the model.

Installation

Configuration

Complete the following steps.

Step 1 - Create and configure the filter component

The purpose of the filter component is to instruct the Filter Factory on which filters to instantiate. The list of filter that can be instantiated for a particular model are listed in the getInstantiableFilters() method. These can also be organised by modified the namespace that is returned by the getInstantiableFiltersNamespace() method.

To create a filter component from the command line of your Laravel project, type the Artisan command below, specifying the name of the component.

You are free to name your filter component classes however you choose. The only requirement of a filter component is that it must implement the FilterComponentInterface.

The newly created filter component will be placed in the App\Filters\Components directory and namespace by default.

You can override the default directory \ namespace by passing an optional 2nd argument.

Step 2 - Filter Factory setup

The filter component created in step 1 needs to be injected into the constructor argument of the FilterFactory. You can do this by binding a filter factory instance and injecting the filter component.

Open the App/Providers/AppServiceProvider.php file and create a new binding for the FilterFactory in the register() method, specifying an alias for the Factory. Then pass the component into the FilterFactory constructor using the $app->make()method.

You can use the code below as a template, replacing “FactoryAlias” and “YourComponent”.

Step 3- Create Filters

The filters that are created will be put in the App\Filters directory and namespace by default.

You can override the default directory \ namespace by passing an optional 2nd argument

Once a filter has been created for a particular model, you will need to update the getInstantiableFilters() method on the filter component so that the factory can create the filter.

Step 4- The Filterable Trait

Add the Filterable trait to the model that you want to filter:

The filterable trait exposes the getFilterFactory() method to the model and is used to retrieve the FilterFactory instance from the IOC (inversion of control) container.

You also need to add the code snippet below to your model, replacing 'YourFilterFactory' with the name (alias) of the factory that was setup in step 2

The scopeFilters method provides easy access to the FilterFactory that was setup in the IOC container in Step 2.

Usage

The example below is calling the Filters() method from a repository, but the concept is that same if used directly in a model or controller.

With any of your existing queries you can call the Filters() method, passing through the $request->input(). This will dynamically instantiate and apply the filters to the model.


All versions of filterable with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3||^8.0
laravel/framework Version ^6.0||^7.0||^8.0||^9.0||^10.0||^11.0||^12.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 webdevjohn/filterable contains the following files

Loading the files please wait ....