{"id":15286634,"url":"https://github.com/etcinit/purifier","last_synced_at":"2025-10-07T01:31:00.241Z","repository":{"id":24563896,"uuid":"27971221","full_name":"etcinit/purifier","owner":"etcinit","description":"A HTMLPurifier service for Laravel 5","archived":false,"fork":true,"pushed_at":"2015-08-20T21:10:42.000Z","size":502,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-01T15:17:46.106Z","etag":null,"topics":["composer","html-escape","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mewebstudio/Purifier","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etcinit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-13T19:25:19.000Z","updated_at":"2017-10-20T06:03:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/etcinit/purifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fpurifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fpurifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fpurifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etcinit%2Fpurifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etcinit","download_url":"https://codeload.github.com/etcinit/purifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235575693,"owners_count":19012156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","html-escape","laravel","php"],"created_at":"2024-09-30T15:17:46.117Z","updated_at":"2025-10-07T01:30:59.919Z","avatar_url":"https://github.com/etcinit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Purifier](https://github.com/etcinit/purifier) [![Build Status](https://travis-ci.org/etcinit/purifier.svg?branch=master)](https://travis-ci.org/etcinit/purifier)\n\nA HTMLPurifier service for Laravel 5\n\n## Installation\n\n\u003e Note: This package is for Laravel 5 only. It does not include a Facade and \n\u003e it requires certain \"Contracts\" interfaces only available in Laravel 5. \n\nThis package can be installed via [Composer](http://getcomposer.org) by \nrequiring the `chromabits/purifier` package in your project's `composer.json`:\n\n```json\n{\n    \"require\": {\n        \"laravel/framework\": \"~5.0\",\n        \"chromabits/purifier\": \"~2.1\"\n    }\n}\n```\n\nUpdate your packages with `composer update` or install with `composer install`.\n\n## Usage\n\nTo use the HTMLPurifier service, you must register the service provider when \nbootstrapping your Laravel application.\n\nFind the `providers` key in `config/app.php` and register the HTMLPurifier \nService Provider:\n\n```php\n    'providers' =\u003e [\n        // ...\n        'Chromabits\\Purifier\\PurifierServiceProvider',\n    ]\n```\n\nAfter registering the provider, classes requiring the \n`Chromabits\\Purifier\\Contracts\\Purifier` contract will get the purifier service \ninstance through dependency injection (See below for examples).\n\n## Configuration\n\nTo use your own settings, copy the `config/purifier.php` file in this package \ninto your application's `config` directory, and modify as needed.\n\nYou can define mutiple sets of configurations by sspecifying new entries in the \n`settings` array key:\n\n```php\nreturn [\n    \"settings\" =\u003e [\n        \"default\" =\u003e [\n            \"HTML.SafeIframe\" =\u003e 'true',\n            \"URI.SafeIframeRegexp\" =\u003e \"%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%\",\n        ],\n        \"titles\" =\u003e [\n            'AutoFormat.AutoParagraph' =\u003e false,\n            'AutoFormat.Linkify' =\u003e false,\n        ]\n    ],\n];\n```\n\nThe service will use the `default` key as the default set of configuration, \nany other configuration will extend this. If a configuraiton file is not \nprovided, the service will use safe defaults.\n\n## Example\n\nFull usage example with default settings within a Laravel 5 controller:\n\n```php\n\u003c?php\n\nnamespace Http\\Controllers;\n\nuse Chromabits\\Purifier\\Contracts\\Purifier;\nuse HTMLPurifier_Config;\nuse Illuminate\\Http\\Request;\n\n/**\n * Class IndexController\n *\n * @package App\\Http\\Controllers;\n */\nclass IndexController {\n\t/**\n\t * @var Purifier\n\t */\n\tprotected $purifier;\n\t\n\t/**\n\t * Construct an instance of MyClass\n\t *\n\t * @param Purifier $purifier\n\t */\n\tpublic function __construct(Purifier $purifier) {\n\t\t// Inject dependencies\n\t\t$this-\u003epurifier = $purifier;\n\t}\n\t\n\t/**\n\t * Get index page\n\t *\n\t * @param Request $request\n\t */\n\tpublic function getIndex(Request $request)\n\t{\n\t\treturn $this-\u003epurifier-\u003eclean($request-\u003einput('first_name'));\n\t}\n}\n```\n\nWith dynamic configuration:\n\n```php\n\t// Using config entries from purifier.php\n\t$this-\u003epurifier-\u003eclean('This is my H1 title', 'titles');\n\t\n\t// Passing configuration from an array (inherits default config)\n\t$this-\u003epurifier-\u003eclean(\n\t\t'This is my H1 title',\n\t\t[ 'Attr.EnableID' =\u003e true ]\n\t);\n```\n\nInteracting with the `HTMLPurifier_Config` object directly using a custom \nservice provider and Closure:\n\n```php\n\u003c?php\n\nnamespace App\\Providers;\n\nuse Chromabits\\Purifier\\Purifier;\nuse Illuminate\\Support\\ServiceProvider;\n\n/**\n * ...\n */\nclass CustomPurifierServiceProvider extends ServiceProvider\n{\n    /**\n     * Register the service provider.\n     *\n     * @return void\n     */\n    public function register()\n    {\n        // Bind contract with concrete implementation\n        $this-\u003eapp-\u003ebind(\n        \t'Chromabits\\Purifier\\Contracts\\Purifier',\n        \tfunction ($app) {\n          \t\tnew Purifier($app, $app['config'], function (HTMLPurifier_Config $config) {\n                \t\t// Do stuff with $config here\n                \t\treturn $config;\n                }\n            }\n        );\n    }\n}\n```\n\n# License\n\nBased on the \n[Laravel 4 Purifier service]((https://github.com/mewebstudio/purifier)) \n\nSee **LICENSE.md** for license information\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetcinit%2Fpurifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetcinit%2Fpurifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetcinit%2Fpurifier/lists"}