Download the PHP package pugx/filter-bundle without Composer

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

PUGX FilterBundle

Total Downloads Build Status

The purpose of this bundle is to provide a way to get some filters that stay in session, to be able to use them when displaying a list of items. It also supports sorting.

Setup

Run

No configuration is required.

Basic Usage

Inject the provided service in your controller and use it with a form.

Your form should use QUERY (see below) or GET as method, use some fields that make sense on your list of items, and not use CSRF protection.

The first step is saving the filter with a name (if the form is submitted). Then, you can get a key/value array in $filter->filter('foo'), where "foo" is the name you provided above.

Using such an array to retrieve the filtered value is up to you: this bundle makes no assumptions about your domain and doesn't do magic.

Here is an example:

Form Example

QUERY Method

The QUERY method is the preferred one: it's safe like GET, but filter values travel in the request body instead of the URL. GET is still supported and stays the default of AbstractFilterType.

To use it, set QUERY as method of your form:

No changes are needed in your controller, except for the accepted methods.

Browsers can't submit a form with QUERY method, so Symfony renders it as POST with a hidden _method field. The bundle accepts both:

Sorting

You can use the provided Twig extension for column sorting functionality.

Example of template:

You need to provide a route/action to perform sorting, using $filter->sort('foo', $field, $direction).

Then, you'll find an additional value inside your filter array, like this:

You can use this value to perform your sorting (again, this is up to you, and it depends on your domain logic).

Translation

Translations are available (for now, only for English/French/Italian).

The translations should be automatically discovered.

JavaScript

A jQuery helper is provided to enhance UX. You can use it by requiring the following line in your package.json file:

Then you can do something like the following:

The basic results will be that the icon in the toggle button will be toggled along, and the arrow will point to the right when filters are shown (and back to the bottom when the filters are collapsed). If the form uses the QUERY method, it will be submitted with a real QUERY request. When the filter is saved, the current page is reloaded: the redirect destination of your controller is ignored, since JavaScript can't read it. If you redirect elsewhere (e.g. dropping the page number), don't use the helper on that form: the POST fallback follows the redirect. If the QUERY request fails, the form is submitted again with the POST fallback.

You can pass an option object to pugxFilter function.

Currently supported options are:

If you prefer vanilla JavaScript with Bootstrap, you can use the following snippet:

Helpers

The following helper functions are available as functions in Twig templates:


All versions of filter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
symfony/config Version ^6.4 || ^7.4 || ^8.0
symfony/dependency-injection Version ^6.4 || ^7.4 || ^8.0
symfony/form Version ^6.4 || ^7.4 || ^8.0
symfony/http-kernel Version ^6.4 || ^7.4 || ^8.0
symfony/service-contracts Version ^2.5 || ^3.0
twig/twig Version ^3.11
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 pugx/filter-bundle contains the following files

Loading the files please wait ...