PHPackages                             2media/policies-builder - 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. 2media/policies-builder

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

2media/policies-builder
=======================

PHP Package to generate policies for websites

v1.9.0(1y ago)2571MITPHPPHP ^8.4CI passing

Since Apr 22Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/2media/policies-builder)[ Packagist](https://packagist.org/packages/2media/policies-builder)[ Docs](https://github.com/2media/policies-builder)[ RSS](/packages/2media-policies-builder/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (10)Versions (15)Used By (0)

2media Policies Builder
=======================

[](#2media-policies-builder)

[![Tests](https://github.com/2media/policies-builder/actions/workflows/run-tests.yml/badge.svg)](https://github.com/2media/policies-builder/actions/workflows/run-tests.yml)[![Check & fix styling](https://github.com/2media/policies-builder/actions/workflows/laravel-pint-fixer.yml/badge.svg)](https://github.com/2media/policies-builder/actions/workflows/laravel-pint-fixer.yml)

A PHP package to build and generate policies for landingpages and websites. It currently supports the following policies:

- Terms of Service
- Imprint
- Privacy Policy
- Conditions of Participation

```
'policies' => PoliciesConfiguration::make()
    ->languages(['de', 'fr', 'it', 'en'])
    ->domain('example.ch')
    ->brand('2media')
    ->types([
        TermsOfService::make(),
        Imprint::make()
            ->imageCopyrights([
                Copyright::make('Picasso', 'Adobe Stock', 'Hero Image 1'),
            ]),
    ]),
```

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

[](#installation)

The package can be installed via composer.

```
composer require 2media/policies-builder
```

Usage
-----

[](#usage)

### Jigsaw

[](#jigsaw)

Before you can start generating policies with the package, you need to first configure your Jigsaw project.

#### Collection &amp; Template

[](#collection--template)

Add a new remote collection to your project. Add the following line to your projects `config.php`. (If you already use collections in your project, only add the `policies` key to your existing `collections`-array.)

```
'collections' => [
    'policies' => [
        'items' => fn(Collection $config) => (new PoliciesCollection())->generate($config),
    ],
],
```

This remote collection will be responsible for generating all configured policies.

In addition create a new layout file under `source/_layouts.policy`. All generated policies will extend this layout file.

#### Policies Configuration

[](#policies-configuration)

Next, add a `policies` key to your projects `config.php` with a `PoliciesConfiguration` instance.

```
'policies' => PoliciesConfiguration::make()
    ->languages(['de'])
    ->domain('example.com')
    ->brand('2media')
    ->types([
        // Policies Objects
    ]),
```

The `PoliciesConfiguration`-object holds configuration values which are used by all policies. See below for supported methods.

##### `languages([])`

[](#languages)

**Required**. Accepts an array of ISO-639-1 language codes for which policies should be generated.

We currently support:

- `de` (German)
- `fr` (French)
- `it` (Italian)
- `en` (English)
- `es` (Spanish)
- `pt` (Portuguese)
- `sr` (Serbian)
- `sq` (Albanian)
- `tr` (Turkish)
- `pl` (Polish)

##### `domain(string)`

[](#domainstring)

**Required**. The domain of the project.

##### `brand(string)`

[](#brandstring)

Optional. Defaults to `2media`. Define for which brand the policies should be generated. Depending on the brand, different policies are generated.

##### `variant(string)`

[](#variantstring)

Optional. Defaults to `default`. Define which variant of policies you would like use in this project.

> TODO: Needs better documentation and examples.

##### `types([])`

[](#types)

**Required**. An array of configured policies. See [Supported Policies](#supported-policies) for details.

#### Supported Policies

[](#supported-policies)

The following policies can currently be built with this package.

##### Terms of Service

[](#terms-of-service)

By adding the following policy to the `type()` method of the `PoliciesConfiguration` a terms of service policy is being generated.

```
TermsOfService::make(),
```

If the website is operated in cooperation with a different company, use the `inCooperationWith()` method to indicate this in the terms of service. (Note that not all variants support this feature.)

```
use Twomedia\PoliciesBuilder\DTOs\CooperationPartner;
use Twomedia\PoliciesBuilder\Policies\TermsOfService;

TermsOfService::make()
    ->inCooperationWith(CooperationPartner::make(
        'Legal Name',
        'Name',
        'https://example.com'
    ));
```

If the website is operated on behalf of a different company, use the `onBehalfOf()` method to indicate this in the terms of service. (Note that not all variants support this feature).

```
use Twomedia\PoliciesBuilder\DTOs\CooperationPartner;
use Twomedia\PoliciesBuilder\Policies\TermsOfService;

TermsOfService::make()
    ->onBehalfOf(CooperationPartner::make(
        'Legal Name',
        'Name',
        'https://example.com'
    ));
```

##### Imprint

[](#imprint)

To generate imprints, add the following code to the `type()` method of the `PoliciesConfiguration`. Optionally, the package also generates an image copyright section for you.

```
Imprint::make()
    ->imageCopyrights([
        Copyright::make('Author', 'source.com', 'Internal Note'),
    ]),
```

**`imageCopyrights([Stringable])`**

Optional. Use the `imageCopyrights()` method and the `Copyright`-object to define the image copyrights of the project. If the project contains Icons which you do not want to list each on it's own use the `IconCopyright`-object.

**Please always use the domain of the source instead of its name.**

(Note the example below assumes you use PHP 8.0 and [Named Arguments](https://stitcher.io/blog/php-8-named-arguments))

```
// © Picasso / unsplash.com
Copyright::make(author: 'Picasso', source: 'unsplash.com', description: 'Hero Image');

// Icons © thenounproject.com
IconCopyright::make(source: 'thenounproject.com');
```

If none of the above classes solve the Copyright question for your project, feel free to create your own Copyright class. It just needs to implement the `Twomedia\PoliciesBuilder\Contracts\Stringable` interface – meaning just add a `__toString` method to your class.

```
new class() implements Stringable {
    public function __toString()
    {
        return 'Anonymous Copyright Class';
    }
}
```

##### Privacy Policy

[](#privacy-policy)

By adding the following policy to the `type()` method of the `PoliciesConfiguration` a privacy policy is being generated.

```
PrivacyPolicy::make(),
```

*There are currently no specific configuration options available for `PrivacyPolicy`.*

##### Conditions of Participation

[](#conditions-of-participation)

To generate a "Conditions of Participation" policy for competition campaigns, add the following block to the `type()` method of the `PoliciesConfiguration`.

```
ConditionsOfParticipation::make();
```

**`closingDate(string)`**

Use the `closingDate()` method to pass the end date of the competition to the policy.

```
ConditionsOfParticipation::make()
    ->closingDate('31.12.2030');
```

#### Global Translations

[](#global-translations)

Instead of defining the translations for the names of the policies ("Impressum", "Conditions d’utilisation") for the policies in your Jigsaw project, you can use the `GlobalTranslator` that comes with the package.

The `GlobalTranslator` connects with our Webservice and gets the translations from a central place. If you follow these directions, the HTTP requests won't have any impact on the build time, as the requests/responses are cached for 24 hours on your machine.

**Setup Caching**As Jigsaw doesn't expose a Cache system like in a normal Laravel application, we have to do it ourselves. Add the following line to your `bootstrap.php` file to register the packages cache into the Jigsaw Container.

```
$events->beforeBuild(\Twomedia\PoliciesBuilder\Cms\Jigsaw\Listeners\RegisterCacheInContainer::class);
```

**Add `transGlobal` function**Add the following line to your projects `config.php` to expose the `GlobalTranslator` in your projects blade templates.

```
'transGlobal' => function ($page, $key, array $replace = []) {
    return Container::getInstance()->make(GlobalTranslator::class)->trans($page, $key, $replace);
},
```

In your templates, you can now use `transGlobal()` method to get translated strings for all the policies.

```
{{ $page->transGlobal('global.imprint') }}
{{ $page->transGlobal('global.terms') }}
{{ $page->transGlobal('global.privacy') }}
{{ $page->transGlobal('global.conditions_of_participation') }}
```

**Available Translations Keys**

The following translations keys are currently available:

- `global.imprint`
- `global.terms`
- `global.privacy`
- `global.conditions_of_participation`

The key are defined by the Webservice app. You can find the German version of the available keys [here](https://github.com/2media/webservice-neo/blob/master/public/lang/de/policies.json).

### Statamic

[](#statamic)

> The package currently doesn't support Statamic yet.

Install local version in a project
----------------------------------

[](#install-local-version-in-a-project)

If you're working on the package locally and want to test thing in a demo project you can use the [composer path-repository format](https://getcomposer.org/doc/05-repositories.md#path). Add the following snippet to the `composer.json` in your demo project.

```
{
    "repositories": [
        {
            "type": "path",
            "url": "/path/to/policies-builder/",
            "options": {
                "symlink": true
            }
        }
    ],
}
```

And "install" the package with `composer require 2media/policies-builder` or `composer update 2media/policies-builder`. The package should now be symlinked in your demo project.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stefan Zweifel](https://github.com/stefanzweifel)
- [Lena Fuchs](https://github.com/mlfuchs)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance46

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% 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 ~104 days

Recently: every ~195 days

Total

14

Last Release

541d ago

PHP version history (5 changes)v1.0.0PHP ^7.4|^8.0

v1.4.0PHP ^7.4 | ^8.0

v1.5.0PHP ^8.0

v1.6.0PHP ^8.1

v1.9.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e6863f43d55dc6b14a20fb07537f8609b80a4bb7c08a64a4fc11951263db67c?d=identicon)[2media-bot](/maintainers/2media-bot)

---

Top Contributors

[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (140 commits)")[![mlfuchs](https://avatars.githubusercontent.com/u/606312?v=4)](https://github.com/mlfuchs "mlfuchs (5 commits)")

---

Tags

twomediapolicies-builder

###  Code Quality

TestsPHPUnit

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/2media-policies-builder/health.svg)

```
[![Health](https://phpackages.com/badges/2media-policies-builder/health.svg)](https://phpackages.com/packages/2media-policies-builder)
```

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.0k1](/packages/mike-bronner-laravel-model-caching)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)

PHPackages © 2026

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