PHPackages                             shakaran/adstxtparser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. shakaran/adstxtparser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

shakaran/adstxtparser
=====================

A open source implemation in PHP of Ads.txt Specification Version 1.0.1 (OpenRTB working group)

1.0(7y ago)5469↓33.3%1[1 PRs](https://github.com/shakaran/adstxtparser/pulls)AGPL-3.0-or-laterPHPPHP &gt;=7.0

Since Jun 14Pushed 2y ago4 watchersCompare

[ Source](https://github.com/shakaran/adstxtparser)[ Packagist](https://packagist.org/packages/shakaran/adstxtparser)[ RSS](/packages/shakaran-adstxtparser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

AdsTxtParser
============

[](#adstxtparser)

[![PRs Welcome](https://camo.githubusercontent.com/dd0b24c1e6776719edb2c273548a510d6490d8d25269a043dfabbd38419905da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e737667)](https://github.com/shakaran/adstxtparser/issues?utf8=%E2%9C%93&q=is%3Aopen%20is%3Aissue)[![Build Status](https://camo.githubusercontent.com/229b84f5d6f5a3f8126904713fbb15ae21061b0721ac43aa031d6f068e40a24d/68747470733a2f2f7472617669732d63692e6f72672f7368616b6172616e2f6164737478747061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/shakaran/adstxtparser)[![Latest Stable Version](https://camo.githubusercontent.com/73e9f5998f02d097142e9355f6390000cf8cd1c9a9fea74c1d7a722e6da5389c/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f616473747874706172736572652f762f737461626c652e706e67)](https://packagist.org/packages/shakaran/adstxtparser)[![Latest Unstable Version](https://camo.githubusercontent.com/8f7403bbfbb6eb7a2e45d17c4538e998c790ac35f4ca6b48e66e63a165cb4cb5/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f6164737478747061727365722f762f756e737461626c65)](https://packagist.org/packages/shakaran/adstxtparser)[![License](https://camo.githubusercontent.com/37bfc0b18763299cce40498ca8b16ac36c0f99d4a919fe12e8b6b5a63bc82d4c/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f6164737478747061727365722f6c6963656e7365)](https://packagist.org/packages/shakaran/adstxtparser)

[![Total Downloads](https://camo.githubusercontent.com/a07f23382ca7da2c88917510abdf506f8a9859f6acdf423ac6c1d66c1ae08f0c/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f6164737478747061727365722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/shakaran/adstxtparser)[![Monthly Downloads](https://camo.githubusercontent.com/01531fceb384fdf2eb181bf396aea9b5d97fa8a298089d8cb35c24db9f8f58dc/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f6164737478747061727365722f642f6d6f6e74686c79)](https://packagist.org/packages/shakaran/adstxtparser)[![Daily Downloads](https://camo.githubusercontent.com/f0a7ef160b8fb23ba91ecefa4ac2dfe8e992dc46bb0ed4e69b6549a0d727ad48/68747470733a2f2f706f7365722e707567782e6f72672f7368616b6172616e2f6164737478747061727365722f642f6461696c79)](https://packagist.org/packages/shakaran/adstxtparser)

A open source implentation in PHP of [Ads.txt Specification Version 1.0.1](https://iabtechlab.com/wp-content/uploads/2017/09/IABOpenRTB_Ads.txt_Public_Spec_V1-0-1.pdf) (OpenRTB working group)

[![Graph Ads.txt](https://camo.githubusercontent.com/4c2eea50ff2f891aceda1a63b8478ae4306c73423afec56dbaffcef6e32fd4a9/68747470733a2f2f692e696d6775722e636f6d2f4e6e5643487a392e706e67)](https://camo.githubusercontent.com/4c2eea50ff2f891aceda1a63b8478ae4306c73423afec56dbaffcef6e32fd4a9/68747470733a2f2f692e696d6775722e636f6d2f4e6e5643487a392e706e67)

Note: ADS = Authorized Digital Sellers DSP = Demand Side Platforms

WHAT IS ADS.TXT?
----------------

[](#what-is-adstxt)

Ads.txt is an initiative by the Interactive Advertising Bureau to enable publishers to take control over who can sell their ad inventory.

Since 01 Nov 2017 Google is filtering traffic based on ads.txt

It is a simple logic of the textfile as mechanism to fight adfraud

Widely accepted and implemented by more and more publishers, ssp and dsp.

Can prevent advertisers from buying invalid traffic.

[Check more info](https://iabtechlab.com/ads-txt/) about it.

Donate
------

[](#donate)

I am a freelancer [Senior Backend Engineer](https://upwork.com/fl/angelguzmanmaeso#/) working on my free time for develop this.

If you want pay me some beer or severals to appreciate the efforts:

[![paypal](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KY8JY46S5WPWS)

Setup
-----

[](#setup)

Install with composer with only:

```
composer require shakaran/adstxtparser

```

TECHNICAL NOTES
---------------

[](#technical-notes)

Requires PHP 7.0+.

How to use
----------

[](#how-to-use)

A quick use to instanciate and run over a domain is:

```
use AdsTxtParser\Parser;

$parser = new Parser();
$parser->readExternalFile('http://estaticos.elmundo.es');
```

Note: that you only have to pass as argument the domain.

After you already fetch the data in the Parser object, you can query about errors:

```
$errors = $parser->getErrors();
```

Or warnings:

```
$warnings = $parser->getWarnings();
```

Or get the variables defined:

```
$variables = $parser->getVariables();
```

Or get the fields defined:

```
$fields = $parser->getFields();
```

Or get the comments defined:

```
$comments = $parser->getComments();
```

Even more complex operations, as know the list of resellers:

```
$resellers = $parser->getResellers();
```

Or the list or directs:

```
$directs = $parser->getDirects();
```

A complex example using all the options could be:

```
try
        {
            // By default localhost
            $parser = new Parser();
            $parser->readExternalFile('http://estaticos.elmundo.es');

            // More examples to test:
            // https://elpais.com/ads.txt
            // https://www.elconfidencial.com/ads.txt
        }
        catch(AdsFileNotFound $e)
        {
            echo $e->getMessage();
        }

        $comments = $parser->getComments();
        // var_dump($comments);

        $errors = $parser->getErrors();
        //var_dump($errors);

        $warnings = $parser->getWarnings();
        // var_dump($warnings);

        $fields = $parser->getFields();
        // var_dump($fields);

        $variables = $parser->getVariables();
        //var_dump($variables);

        $resellers = $parser->getResellers();
        //var_dump(count($resellers));

        $directs = $parser->getDirects();
        //var_dump(count($directs));
```

Tests
-----

[](#tests)

Executing the tests:

Run a local webserver under Test directory:

```
cd Tests; sudo php -S localhost:80

```

```
vendor/phpunvendor/phpunit/phpunit/phpunit --configuration=Tests/phpunit.xml --include-path=Tests
```

License
-------

[](#license)

AGPLv3 or later, see [LICENSE](LICENSE) file for more details.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2896d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/788e71aeadaf4a25f474ea131827621a526db45b949ae0baa5f2a9dbc39ab8f1?d=identicon)[shakaran](/maintainers/shakaran)

---

Top Contributors

[![shakaran](https://avatars.githubusercontent.com/u/14254?v=4)](https://github.com/shakaran "shakaran (36 commits)")

---

Tags

advertisement-managementadvertisersadvertisingadvertising-apiadvertising-toolcomposer-packagelibraryphpphp7phpadsparserspecificationadstxtparseradstxtopenrtb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shakaran-adstxtparser/health.svg)

```
[![Health](https://phpackages.com/badges/shakaran-adstxtparser/health.svg)](https://phpackages.com/packages/shakaran-adstxtparser)
```

###  Alternatives

[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1921.3M14](/packages/simplehtmldom-simplehtmldom)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[romanpitak/nginx-config-processor

Nginx configuration files processor.

7235.3k1](/packages/romanpitak-nginx-config-processor)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

266.7k](/packages/leonelquinteros-php-toml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
