PHPackages                             yaroslawww/laravel-ad-director - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yaroslawww/laravel-ad-director

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yaroslawww/laravel-ad-director
==============================

Package to help you add advertising to your site.

1.1.0(2y ago)0621MITPHPPHP ^8.0

Since Dec 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yaroslawww/laravel-ad-director)[ Packagist](https://packagist.org/packages/yaroslawww/laravel-ad-director)[ Docs](https://github.com/yaroslawww/laravel-ad-director)[ RSS](/packages/yaroslawww-laravel-ad-director/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (5)Used By (1)

Laravel advertising manager.
============================

[](#laravel-advertising-manager)

[![Packagist License](https://camo.githubusercontent.com/cb8c00e3f8dfd98b2b0f9a4fe7e90c507355978a59abd811818b2f39ea19e611/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7961726f736c617777772f6c61726176656c2d61642d6469726563746f723f636f6c6f723d253233346463373166)](https://camo.githubusercontent.com/cb8c00e3f8dfd98b2b0f9a4fe7e90c507355978a59abd811818b2f39ea19e611/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7961726f736c617777772f6c61726176656c2d61642d6469726563746f723f636f6c6f723d253233346463373166)[![Packagist Version](https://camo.githubusercontent.com/e20599175f7a88ed6e8fd22acab586a6eaca988930813b1e74585d3b260b5f64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7961726f736c617777772f6c61726176656c2d61642d6469726563746f72)](https://packagist.org/packages/yaroslawww/laravel-ad-director)[![Total Downloads](https://camo.githubusercontent.com/b6e598719aa2d182f4459727135f7d1aa9de12112761f8e572b1a669ba597b63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7961726f736c617777772f6c61726176656c2d61642d6469726563746f72)](https://packagist.org/packages/yaroslawww/laravel-ad-director)[![Build Status](https://camo.githubusercontent.com/384c1378113cdac36f4ce05852a15ad7d6a6650e841ccba018eff68ce9008986/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d61642d6469726563746f722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-ad-director/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/50e8a6605c12468e483c8665564f6804561187467349d50033042c04d6ef1eb4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d61642d6469726563746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-ad-director/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0e006fe30acc584eaf949a65a0e29c2069a5dd5465725e71a13ba149ccd9790d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7961726f736c617777772f6c61726176656c2d61642d6469726563746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yaroslawww/laravel-ad-director/?branch=master)

Package to help you add advertising to your site.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require yaroslawww/laravel-ad-director
```

Optionally you can publish the config file with:

```
php artisan vendor:publish --provider="AdDirector\ServiceProvider" --tag="config"
```

Supported services
------------------

[](#supported-services)

- [Google Publisher Tags](https://developers.google.com/publisher-tag/reference)
- to add new services, please send PR.

Usage
-----

[](#usage)

If you use Google Publisher Tags, and use repeated sizes - you can easily configure global sizes with size mapping in any service provider - as GPT is singleton.

```
use AdDirector\Facades\AdDirector;
use AdDirector\GPT\SizeMap;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        AdDirector::gpt()
        // Add size with mapping example
        ::addSize('leaderboard', new \AdDirector\GPT\Size(
            // Allowed sizes
            [[728, 90], [320, 50]],
            // Responsive size map
            (new SizeMap())
                          // Tablet
                          ->addSize([1024, 768], [728, 90])
                          ->addSize([980, 690], [728, 90])
                          // Desktop
                          ->addSize([1050, 200], [728, 90])
                          // Mobile
                          ->addSize([640, 480], [320, 50])
                          // Any size
                          ->addSize([0, 0], [320, 50])
        ))
        // Add static size without responsive
        ::addSize('medium_rectangle', new \AdDirector\GPT\Size([300, 250]));
    }
}
```

On page controller you can configure set of advert locations.

```
use AdDirector\Facades\AdDirector;
use AdDirector\GPT\Slot;

class FrontpageController extends Controller
{
    public function __invoke()
    {
        AdDirector::gpt()
                  ->addLocation(Slot::make(
                      '/1234567/FOO_Leaderboard',
                      // Size name from global config
                      'leaderboard',
                      // Optional, if not set will be generated automatically
                      'div-gpt-ad-1234567890001-0'
                      // Location identifier, if not set will be used slot's adUnitPath
                  )
                  // Set targeting
                  ->addTarget('foo', 'bar')
                  ->addTarget('baz', ['foo', 'bar'])
             , 'header-ads')

                  ->addLocation(Slot::make(
                      '/1234567/FOO_Medium',
                      'medium_rectangle',
                  ), 'medium-ads')

                  ->addLocation(Slot::make(
                      '/1234567/BAR_Leaderboard',
                     // Manually set custom size
                     new \AdDirector\GPT\Size(
                         [[728, 90], [320, 50]],
                         (new SizeMap())
                            ->addSize([1024, 768], [728, 90])
                            ->addSize([640, 480], [320, 50])
                            ->addSize([0, 0], [320, 50])
                     ),
                  ), 'footer-ads');

        return view('frontpage');
    }
}
```

Now there time to add scripts to template

```

    {!! \AdDirector\Facades\AdDirector::configurationScript() !!}

        {!! \AdDirector\Facades\AdDirector::adLocation('header-ads') !!}

        Content

            {!! \AdDirector\Facades\AdDirector::adLocation('medium-ads-ads') !!}

        Content

        {!! \AdDirector\Facades\AdDirector::adLocation('footer-ads') !!}

        {{-- There possible to add any js confitions, timeout, etc.. --}}
        {!! \AdDirector\Facades\AdDirector::displayScript() !!}

```

Credits
-------

[](#credits)

- [![Think Studio](https://camo.githubusercontent.com/8e541bece07d503c85a126b5294865faa00e27371048772f566a0cce8c01fd3a/68747470733a2f2f7961726f736c617777772e6769746875622e696f2f696d616765732f73706f6e736f72732f7061636b616765732f6c6f676f2d7468696e6b2d73747564696f2e706e67)](https://think.studio/)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Every ~195 days

Total

4

Last Release

1010d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23663794?v=4)[yaroslawww](/maintainers/yaroslawww)[@yaroslawww](https://github.com/yaroslawww)

---

Top Contributors

[![yaroslawww](https://avatars.githubusercontent.com/u/23663794?v=4)](https://github.com/yaroslawww "yaroslawww (13 commits)")

---

Tags

laravelad

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yaroslawww-laravel-ad-director/health.svg)

```
[![Health](https://phpackages.com/badges/yaroslawww-laravel-ad-director/health.svg)](https://phpackages.com/packages/yaroslawww-laravel-ad-director)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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