Download the PHP package saeven/zf2-purifier without Composer

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

Soflomo\Purifier

Soflomo\Purifier is the HTMLPurifier integration for Zend Framework 2. It provides a Zend\Filter\FilterInterface instance so you can use Soflomo\Purifier directly to filter your html input with your Zend\InputFilter classes. Furthermore, a view helper is provided to help purifying html on the fly in view scripts.

Installation

Soflomo\Purifier is available through composer. Add "soflomo/purifier" to your composer.json list. You can specify the latest stable version of Soflomo\Purifier:

To enable the module in your config/application.config.php file, add an entry Soflomo\Purifier to the list of enabled modules.

Usage

In your input filter configuration, add the htmlpurifier filter to filter the result. An example form:

If your form has the filter plugin manager injected, this should work out-of-the-box. If not, please read how to inject the filter plugin manager.

When you are not able to filter the html when it is inserted into the database, you might want to filter the html in your view. Please be aware HTMLPurifier is not a very fast library and as such, filtering on every request can be a significant performance bottleneck. Be advised to use a caching mechanism to cache the output of the filtered html. The view helper is available under the key htmlPurifier:

And there is a shorthand available too:

Inject Filter Manager

If you instantiate your form with new FormClass, the plugin manager for filters is not injected. As such, you get a ServiceNotFoundException: "Zend\Filter\FilterPluginManager::get was unable to fetch or create an instance for htmlpurifier". This means the filter plugin manager does not know about the htmlpurifier plugin.

You can fix this by grabbing the filter plugin manager from the Service Manager and inject it into the form manually:

The library Soflomo\Common has a utility class to inject the filter manager. If you require soflomo\common via composer, you can replace above code with this line:

Speed up performance

HTMLPurifier is not the fastest library, but it is the most secure one to filter html in php. By default, HTMLPurifier uses a large number of classes and inclusion of all the files slows down performance during autoloading. You can create a standalone version of the HTMLPurifier class, where a single file contains most of the classes.

The script in vendor/bin/purifier-generate-standalone generates this file for you. The standalone file is created inside vendor/ezyang/htmlpurifier/library (there is nothing to configure about that) so make sure you can write in that directory. The Soflomo\Purifier library helps you to use this standalone version by the configuration option soflomo_prototype.standalone. In your config/autoload/local.php:

If your composer does not load the libraries into vendor/, you can update the path to the standalone version too:

Configure HTMLPurifier

The HTMLPurifier has a class HTMLPurifier_Config where it is possible to configure the purifier rules. Most configuration rules are based on a key/value pair: $config->set('HTML.Doctype', 'HTML 4.01 Transitional');. This mapping is copied to Zend Framework 2 configuration files, so you can easily modify HTMLPurifiers configation:


All versions of zf2-purifier with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3.
ezyang/htmlpurifier Version >=4.5.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 saeven/zf2-purifier contains the following files

Loading the files please wait ....