PHPackages                             codenamephp/deployer.base - 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. [CLI &amp; Console](/categories/cli)
4. /
5. codenamephp/deployer.base

ActiveLibrary[CLI &amp; Console](/categories/cli)

codenamephp/deployer.base
=========================

Base package that provides the very basic task interface, function abstraction and some initial tasks useful for all projects like transferring files

3.2.0(2y ago)010.2k2[1 issues](https://github.com/codenamephp/deployer.base/issues)[1 PRs](https://github.com/codenamephp/deployer.base/pulls)7Apache-2.0PHPPHP ^8.1CI passing

Since Feb 5Pushed 1y agoCompare

[ Source](https://github.com/codenamephp/deployer.base)[ Packagist](https://packagist.org/packages/codenamephp/deployer.base)[ RSS](/packages/codenamephp-deployerbase/feed)WikiDiscussions release Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (8)Used By (7)

Deployer Base
=============

[](#deployer-base)

[![Lines of code](https://camo.githubusercontent.com/020cb98b7aecd659783e8298be8d2918a6003d13d4bd241b0bd56c9f37178bb6/68747470733a2f2f696d672e736869656c64732e696f2f746f6b65692f6c696e65732f6769746875622f636f64656e616d657068702f6465706c6f7965722e62617365)](https://camo.githubusercontent.com/020cb98b7aecd659783e8298be8d2918a6003d13d4bd241b0bd56c9f37178bb6/68747470733a2f2f696d672e736869656c64732e696f2f746f6b65692f6c696e65732f6769746875622f636f64656e616d657068702f6465706c6f7965722e62617365)[![GitHub code size in bytes](https://camo.githubusercontent.com/c50dfd73a954a188e812efe3e6b5440fa224cc917fe637381db3103fa0b8d0d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636f64656e616d657068702f6465706c6f7965722e62617365)](https://camo.githubusercontent.com/c50dfd73a954a188e812efe3e6b5440fa224cc917fe637381db3103fa0b8d0d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636f64656e616d657068702f6465706c6f7965722e62617365)[![GitHub](https://camo.githubusercontent.com/0cb629ee8059cbc3e8e1705bfc295965c6f8fdacfd99a11931f1d6c370831e4d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f64656e616d657068702f6465706c6f7965722e62617365)](https://camo.githubusercontent.com/0cb629ee8059cbc3e8e1705bfc295965c6f8fdacfd99a11931f1d6c370831e4d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f64656e616d657068702f6465706c6f7965722e62617365)

Base package that provides the very basic task interface, function abstraction and some initial tasks useful for all projects like transferring files

What is it?
-----------

[](#what-is-it)

This package is an extension to deployer that adds basic tasks and interfaces and abstracts the actual deployer API. Deployer can still be used as usual but I would recommend implementing your tasks as classes and write unit tests for them. If you have tasks you reuse across projects you should create your own packages. There are already several codenamephp/deployer.\* packages available to use.

### But ... why?

[](#but--why)

I really like testable code and since the actual deploy.php is otherwise just a collection of callbacks that is hard to test I added basic interfaces and classes that encapsulate the tasks and make them reusable.

Sure, you could make it work with lambdas but since PHP is not intended to be a functional programming language it's far easier to just throw some classes into the mix.

Install
-------

[](#install)

Just add the package to composer, ideally by executing `composer require codenamephp/deployer.base` which should install the latest version with semver range.

Usage
-----

[](#usage)

Just create your `deploy.php` as usual. Then just add existing tasks or implement your own and add them using the package functions:

```
const PROJECT_ROOT = __DIR__ . '/..'; // I have deployer in a seperate folder so this makes creating paths easier

$deployerFunctions = new All(); // Abstraction of deployer function and also has some additional methods

$deployerFunctions->registerTask(new UploadTransferables( // My version of deploying code in NEOS projects
  new Simple(PROJECT_ROOT . '/Configuration', '{{release_path}}'),
  new Simple(PROJECT_ROOT . '/DistributionPackages', '{{release_path}}', ['Tests/']),
  new Simple(PROJECT_ROOT . '/Packages', '{{release_path}}'),
  new Simple(PROJECT_ROOT . '/Web', '{{release_path}}', ['_Resources/']),
  new Simple(PROJECT_ROOT . '/flow', '{{release_path}}'),
));

// additional tasks from other packages
$deployerFunctions->task('composer:install', new \de\codenamephp\deployer\composer\task\install\Production())->desc('Run composer install for production.');
$deployerFunctions->task('composer:install:development', new \de\codenamephp\deployer\composer\task\install\Development())->desc('Run composer install for production.');

(new ByTaskListAndMatchers(new AtLeastOne( // clean up the cli list
  new ByRegexTaskName('/provision:?.*/'),
  new ByRegexTaskName('/logs:caddy.*/'),
  new ByRegexTaskName('/deploy:.*/')
)))->hide();
```

### Implementing tasks

[](#implementing-tasks)

Deployer just expects a callable as task so in theory this is everything a task needs. This package contains the `\de\codenamephp\deployer\base\task\iTask` interface that enforces this so we can just add a new instance of the task.

There are also the `\de\codenamephp\deployer\base\task\iTaskWithName` and `\de\codenamephp\deployer\base\task\iTaskWithDescription` interfaces. These can be used to set the description and name of the task directly in the class so we don't have to set the same strings in each project and clutter up our deployment file. At the very least the `\de\codenamephp\deployer\base\task\iTaskWithName` has to be implemented so we can pass the task to `\de\codenamephp\deployer\base\functions\iTask::registerTask` that takes care of the rest.

### Deployer Functions

[](#deployer-functions)

The built in deployer functions require a running Deployer instance and are global so they are very hard to mock. In order for our tasks to be testable there are several `\de\codenamephp\deployer\base\functions\*` interfaces, one for each method or method group. There is also an `\de\codenamephp\deployer\base\functions\iAll` interface that combines them all as convenience if we need several methods. Likewise there's an `\de\codenamephp\deployer\base\functions\All` implementation that acts mostly as a proxy for the global methods and also does some additional type checking.

The interfaces are mostly the same as the deployer built in methods but add some additional type hints and return hints for a cleaner API.

Use these interfaces in your tasks and either use the `\de\codenamephp\deployer\base\functions\All` implementation or write your own. In your tests you can then easily mock these interfaces.

### Host Check

[](#host-check)

Some task should not be executed by accident, for example pushing a database from local to production. This can be easily achieved by adding the `\de\codenamephp\deployer\base\hostCheck\iHostCheck` interface as dependency to your task and calling the `\de\codenamephp\deployer\base\hostCheck\iHostCheck::check` method in your `__invoke()` method.

#### DoNotRunOnProduction

[](#donotrunonproduction)

This implementation assumes the production host actually has the alias "production" (can be changed in constructor) and checks against the current host. If the alias matches an `\de\codenamephp\deployer\base\UnsafeOperationException` is thrown which halts your deployer run. If you have things to clean up (e.g. a database dump) you should add cleanup tasks to the failure step.

#### WithDisallowList

[](#withdisallowlist)

Similar to DoNotRunOnProduction but with a whole list of disallowed aliases.

#### SkippableByOption

[](#skippablebyoption)

This is a decorator for the adding the `\de\codenamephp\deployer\base\hostCheck\iHostCheck` that takes an existing host check but only executes it if the `--cpd:skip-host-check` (or `-cpd:shc` as shorthand) are not set. This way we can skip the host check if we know what we are doing ... at your own risk of course. ;)

### Task Hider / Task Matcher

[](#task-hider--task-matcher)

Deployer comes with a whole set of default tasks, like the whole `provision` namespace. These are usually used once (if at all) and just clutter up the CLI list. The `\de\codenamephp\deployer\base\taskHider\iTaskHider` can be used to hide those tasks you don't want. The default implementation The default implementation `\de\codenamephp\deployer\base\taskHider\ByTaskListAndMatchers` uses a `\de\codenamephp\deployer\base\taskMatcher\iTaskMatcher` implementation to find tasks to hide. There is also a collection that can be used to just add multiple matchers and hide all the matches.

An example could look like this:

```
(new ByTaskListAndMatchers(new AtLeastOne( // clean up the cli list
  new ByRegexTaskName('/provision:?.*/'),
  new ByRegexTaskName('/logs:caddy.*/'),
  new ByRegexTaskName('/deploy:.*/')
)))->hide();
```

### Transferables

[](#transferables)

There is a `\de\codenamephp\deployer\base\transferable\iTransferable` interface that makes file transfers more readable by clearly stating what is local and remote.

### Tasks

[](#tasks)

Maybe I'm going to include an Open API generated manual at some point but for now just check the classes in the `\de\codenamephp\deployer\base\task` namespace.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 96.1% 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 ~140 days

Recently: every ~131 days

Total

6

Last Release

862d ago

Major Versions

1.0.0 → 2.0.02022-07-30

2.0.1 → 3.0.02023-03-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6865819?v=4)[Bastian Schwarz](/maintainers/bastianschwarz)[@bastianschwarz](https://github.com/bastianschwarz)

---

Top Contributors

[![bastianschwarz](https://avatars.githubusercontent.com/u/6865819?v=4)](https://github.com/bastianschwarz "bastianschwarz (74 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

### Embed Badge

![Health badge](/badges/codenamephp-deployerbase/health.svg)

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)[madewithlove/license-checker

CLI tool to verify allowed licenses for composer dependencies

54449.8k21](/packages/madewithlove-license-checker)[shel/neos-terminal

Neos CMS Ui terminal for running Eel expressions and other commands

1441.3k](/packages/shel-neos-terminal)

PHPackages © 2026

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