PHPackages                             laijim/playbook - 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. laijim/playbook

ActiveLibrary

laijim/playbook
===============

0.0.1(6y ago)01PHP

Since Mar 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/laijim/php-playbook)[ Packagist](https://packagist.org/packages/laijim/playbook)[ RSS](/packages/laijim-playbook/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Use php generator ansible playbook file.
========================================

[](#use-php-generator-ansible-playbook-file)

Installation
============

[](#installation)

### The recommended approach is to install the project through [Composer](https://getcomposer.org/).

[](#the-recommended-approach-is-to-install-the-project-through-composer)

```
composer require laijim/php-playbook
```

\#Instantiate

```
//Instantiate
$pb = new \Laijim\Playbook\Playbook(
    new \Laijim\Playbook\Entity\Worker(
        __DIR__ . '/test',
        new \Laijim\Playbook\Entity\LocalHostsFileWriter(),
        new \Laijim\Playbook\Entity\LocalTasksFileWriter(),
        new \Laijim\Playbook\Entity\LocalVariablesFileWriter(),
        new Filesystem()
    )
);

//set host and variables
$pb->setHosts([
    'web' => ['node1', '127.0.0.1'],
    'db' => ['node1', '127.0.0.1'],
])->setVariables([
    'step1' => [
        "var1" => "var1",
        "var2" => "var2"
    ],
    'step2' => [
        "var1" => "var1",
        "var2" => "var2"
    ]
]);

//set tasks
$task1 = new \Laijim\Playbook\Task();
$task1->useHost('web')
    ->useVariables(['step1'])
    ->addTasks([
        ["name" => "debug 1", "debug" => "var=var1"],
        ["name" => "debug 2", "debug" => "var=var2"],
        ["name" => "step 3", "shell" => "echo handlers", "notify" => "step 4"],
    ])->directive('handlers', [
        ["name" => "step 4", "shell" => "echo final"],
    ]);

$task2 = new \Laijim\Playbook\Task();
$task2->useHost('db')
    ->useVariables(['step2'])
    ->addTasks([
        ["name" => "debug 1", "debug" => "var=var1"],
        ["name" => "debug 2", "debug" => "var=var2"],
        ["name" => "step 3", "shell" => "echo handlers", "notify" => "step 4"],
    ])->directive('handlers', [
        ["name" => "step 4", "shell" => "echo final"],
    ]);

//generate playbook files
$pb->register($task1)
->register($task2)
->generate();
```

It will finally generate this directory structure:

```
├── hosts
├── playbook.yaml
└── vars
    ├── step1.yaml
    └── step2.yaml

```

hosts:

```
[web]
node1
127.0.0.1

[db]
node1
127.0.0.1

```

playbook.yaml:

```
        -
        hosts: web
        vars_files:
            - ./vars/step1.yaml
        task:
            -
                name: 'debug 1'
                debug: var=var1
            -
                name: 'debug 2'
                debug: var=var2
            -
                name: 'step 3'
                shell: 'echo handlers'
                notify: 'step 4'
        handlers:
            -
                name: 'step 4'
                shell: 'echo final'
        -
        hosts: db
        vars_files:
            - ./vars/step2.yaml
        task:
            -
                name: 'debug 1'
                debug: var=var1
            -
                name: 'debug 2'
                debug: var=var2
            -
                name: 'step 3'
                shell: 'echo handlers'
                notify: 'step 4'
        handlers:
            -
                name: 'step 4'
                shell: 'echo final'

```

vars/stepN.yaml:

```
var1: var1
var2: var2
```

vars/stepN.yaml:

```
var1: var1
var2: var2
```

Let's test it!
==============

[](#lets-test-it)

```
ansible-playbook -i hosts playbook.yaml
```

Operation result
================

[](#operation-result)

```

PLAY [all] *****************************************************************************************************************************************

TASK [Gathering Facts] *****************************************************************************************************************************
ok: [127.0.0.1]
ok: [node2]

TASK [debug 1] *************************************************************************************************************************************
ok: [127.0.0.1] => {
    "var1": "var1"
}
ok: [node2] => {
    "var1": "var1"
}

TASK [debug 2] *************************************************************************************************************************************
ok: [127.0.0.1] => {
    "var2": "var2"
}
ok: [node2] => {
    "var2": "var2"
}

TASK [step 3] **************************************************************************************************************************************
changed: [127.0.0.1]
changed: [node2]

RUNNING HANDLER [debug 3] **************************************************************************************************************************
changed: [127.0.0.1]
changed: [node2]

PLAY RECAP *****************************************************************************************************************************************
127.0.0.1                  : ok=5    changed=2    unreachable=0    failed=0
node2                      : ok=5    changed=2    unreachable=0    failed=0

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

2236d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/568c32821f46d90005c347899c21a68459c86eb139afe03f34baac97fee020a7?d=identicon)[laijim](/maintainers/laijim)

---

Top Contributors

[![laijim](https://avatars.githubusercontent.com/u/18414943?v=4)](https://github.com/laijim "laijim (1 commits)")

### Embed Badge

![Health badge](/badges/laijim-playbook/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)

PHPackages © 2026

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