idealogica/php-adblock-parser

PHP parser for Adblock Plus filters. A snapshot of abandoned limonte/php-adblock-parser

v0.1.6 2018-03-03 19:36 UTC

This package is auto-updated.

Last update: 2024-04-23 22:18:22 UTC


README

Build Status Scrutinizer Code Quality Code Coverage

Usage

To learn about Adblock Plus filter syntax check these links:

  1. Get filter rules somewhere: write them manually, read lines from a file downloaded from EasyList, etc.:

    $rules = [
        "||ads.example.com^",
        "@@||ads.example.com/notbanner^$~script",
    ];
  2. Create AdblockRules instance from the rules array:

    use Limonte\AdblockParser;
    
    $adblockParser = new AdblockParser($rules);
    $adblockParser->addRules($anotherRules);
  3. Use this instance to check if an URL should be blocked or not:

    $adblockParser->shouldBlock("http://ads.example.com"); // true
    $adblockParser->shouldBlock("http://non-ads.example.com"); // false

Related projects