Download the PHP package exercise/htmlpurifier-bundle without Composer

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

Total Downloads Latest Stable Version License Build Status

ExerciseHTMLPurifierBundle

This bundle integrates HTMLPurifier into Symfony.

Installation

Install the bundle:

Configuration

If you do not explicitly configure this bundle, an HTMLPurifier service will be defined as exercise_html_purifier.default. This behavior is the same as if you had specified the following configuration:

The default profile is special, it is always defined and its configuration is inherited by all custom profiles. exercise_html_purifier.default is the default service using the base configuration.

In this example, a exercise_html_purifier.custom service will also be defined, which includes cache, encoding, HTML tags and attributes options. Available configuration options may be found in HTMLPurifier's configuration documentation.

Note: If you define a default profile but omit Cache.SerializerPath, it will still default to the path above. You can specify a value of null for the option to suppress the default path.

Autowiring

By default type hinting \HtmlPurifier in your services will autowire the exercise_html_purifier.default service. To override it and use your own config as default autowired services just add this configuration:

Using a custom purifier class as default

If you want to use your own class as default purifier, define the new alias as below:

Argument binding

The bundle also leverages the alias argument binding for each profile. So the following config:

will register the following binding:

Form Type Extension

This bundles provides a form type extension for filtering form fields with HTMLPurifier. Purification is done early during the PRE_SUBMIT event, which means that client data will be filtered before being bound to the form.

Two options are automatically available in all TextType based types:

Every type extending TextType (i.e: TextareaType) inherit these options. It also means that if you use a type such as CKEditorType, you will benefit from these options without configuring anything.

Twig Filter

This bundles registers a purify filter with Twig. Output from this filter is marked safe for HTML, much like Twig's built-in escapers. The filter may be used as follows:

Purifiers Registry

A Exercise\HtmlPurifierBundle\HtmlPurifiersRegistry class is registered by default as a service. To add your custom instance of purifier, and make it available to the form type and Twig extensions through its profile name, you can use the tag exercise.html_purifier as follow:

Now your purifier can be used when:

How to Customize a Config Definition

Whitelist Attributes

In some case, you might want to set some rules for a specific tag. This is what the following config is about:

See HTMLPurifier_AttrTypes for more options.

Whitelist Elements

In some case, you might want to set some rules for a specific tag. This is what the following config is about:

Would be equivalent to:

See HTMLPurifier documentation for more details.

Blank Elements

It might happen that you need a tag clean from any attributes. Then just add it to the list:

How to Reuse Profiles

What can really convenient is to reuse some profile definition to build other custom definitions.

In this example the profile named "all" will inherit the "default" profile, then the two custom ones. The order is important as each profile overrides the previous, and "all" could define its own rules too.

Contributing

PRs are welcomed :). Please target the 4.x branch for bug fixes and master for new features.


All versions of htmlpurifier-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ezyang/htmlpurifier Version ~4.14
symfony/config Version ^5.4 || ^6.0 || ^7.0
symfony/dependency-injection Version ^5.4 || ^6.0 || ^7.0
symfony/http-kernel Version ^5.4 || ^6.0 || ^7.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 exercise/htmlpurifier-bundle contains the following files

Loading the files please wait ....