PHPackages                             jkribeiro/composer-hydration - 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. jkribeiro/composer-hydration

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

jkribeiro/composer-hydration
============================

Provides a Composer script to project skeleton hydration by placeholders replacements.

1.1.0(8y ago)5241.7k↓41.3%3[1 issues](https://github.com/jkribeiro/composer-hydration/issues)MITPHP

Since Jun 23Pushed 8y agoCompare

[ Source](https://github.com/jkribeiro/composer-hydration)[ Packagist](https://packagist.org/packages/jkribeiro/composer-hydration)[ RSS](/packages/jkribeiro-composer-hydration/feed)WikiDiscussions 1.x Synced 1mo ago

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

[![Packagist version](https://camo.githubusercontent.com/9c5284d54d4011ab158dbf889dc5cabd857cd3df761646554074c7aa5a874ea7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6b7269626569726f2f636f6d706f7365722d687964726174696f6e2e737667)](https://packagist.org/packages/jkribeiro/composer-hydration)[![Packagist Downloads](https://camo.githubusercontent.com/c68665646343a1d9bd952402acf4e5717c3b1767b822202de17099fec8a523f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6b7269626569726f2f636f6d706f7365722d687964726174696f6e2e737667)](https://packagist.org/packages/jkribeiro/composer-hydration)[![Build Status](https://camo.githubusercontent.com/7980ac0f0a5bba46d827171db993a72f3934e382c4c41aad2042a2e2e078090e/68747470733a2f2f7472617669732d63692e6f72672f6a6b7269626569726f2f636f6d706f7365722d687964726174696f6e2e7376673f6272616e63683d312e78)](https://travis-ci.org/jkribeiro/composer-hydration)

composer-hydration
==================

[](#composer-hydration)

Introduction
------------

[](#introduction)

**composer-hydration** is a simple package that provides a **Composer Script** to be used as placeholder replacement, mostly used by 'skeletons' projects.

Example:

```
composer run-script hydrate -- --replace={FRUIT}:"apple",{INGREDIENT}:"cinnamon"

```

The script will search for the placeholders in `file content`, `file names` and `folders`.

Before:

```
$ /path/composer/project/{FRUIT}.txt
"I love {FRUIT} with {INGREDIENT}, is a good combination!"

```

After:

```
$ /path/composer/project/apple.txt
"I love apple with cinnamon, is a good combination!"

```

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

[](#installation)

### Install Composer

[](#install-composer)

Since **composer-hydration** is a Composer script, you need to [install composer](https://getcomposer.org) first.

> Note: The instructions below refer to the [global composer installation](https://getcomposer.org/doc/00-intro.md#globally). You might need to replace `composer` with `php composer.phar` (or similar) for your setup.

### Add package dependency

[](#add-package-dependency)

Add **composer-hydration** as package dependency of your project, updating your `composer.json`:

```
    "require": {
        ...
        "jkribeiro/composer-hydration": "~1"
    }

```

### Define the Composer Script

[](#define-the-composer-script)

Define the Composer script, adding this entry to your `composer.json`:

```
    "scripts": {
        "hydrate": "Jkribeiro\\Composer\\ComposerHydration::meatOnBones"
    }

```

### Install Project

[](#install-project)

```
composer install

```

Usage
-----

[](#usage)

There are some ways that you can execute this script:

### Execute the command manually

[](#execute-the-command-manually)

After have the package installed, you can run the command manually to have your values placed.

```
composer run-script hydrate -- --replace={SEARCH}:{REPLACE},..."

```

### Hydrate during the Composer Events

[](#hydrate-during-the-composer-events)

Composer fires [some events](https://getcomposer.org/doc/articles/scripts.md#event-names) during its execution process, useful to define on which step/event it will perform the hydration process.

In the example below, the hydration process will occur after the project installation:

```
    "scripts": {
        "hydrate": "Jkribeiro\\Composer\\ComposerHydration::meatOnBones",
        "post-install-cmd": "@composer run-script hydrate -- --replace={{PROJECT_NAMESPACE}}:{%BASENAME%}"
    }

```

Variables as Replacement values
-------------------------------

[](#variables-as-replacement-values)

Sometimes we need to use dynamic replacement values on `composer.json`, not only hardcoded values like `{FRUIT}:banana`, for these cases, there are two possibilities:

### Environment Variables

[](#environment-variables)

`composer.json` allows environment variables as replacement placeholder value, like `{{PROJECT_NAMESPACE}}:$PROJECT_NAME"`, `$PROJECT_NAME` is the variable name. You must define the variables before execute the Composer commands.

Example:
**composer.json**

```
    ...
    "scripts": {
        "hydrate": "Jkribeiro\\Composer\\ComposerHydration::meatOnBones",
        "post-install-cmd": "@composer run-script hydrate -- --replace={{PROJECT_NAMESPACE}}:$PROJECT_NAME"
    }

```

**Execution**

```
$ export PROJECT_NAME="My Project"
$ composer install

```

### "Magic Constants"

[](#magic-constants)

Using the same idea of [PHP Magic constants](http://php.net/manual/en/language.constants.predefined.php), **composer-hydration** provides some Magic constants too.

- `{%BASENAME%}`: Returns the base folder name where the script is being executed, normally is the name of the project.
- `{%UCFIRST_BASENAME%}`: Returns the base folder name with the first character capitalized.
- `{%UPPER_CAMEL_CASE_BASENAME%}`, `{%LOWER_CAMEL_CASE_BASENAME%}`: Returns the base folder name using the upper/lower camel case format. Only the folder name separators '-', '\_' are allowed.

    Example:

    ```
    $ ~/Projects/myproject: composer run-script hydrate -- --replace={{PROJECT_NAMESPACE}}:{%BASENAME%}"

    ```

    Placeholders with `{{PROJECT_NAMESPACE}}` will be replaced by `myproject`.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~85 days

Recently: every ~105 days

Total

6

Last Release

3188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82291593cc1356f74a314304499ad8aa14c24ca61f99e6be72d24e21844457ab?d=identicon)[jkribeiro](/maintainers/jkribeiro)

---

Top Contributors

[![jkribeiro](https://avatars.githubusercontent.com/u/1932061?v=4)](https://github.com/jkribeiro "jkribeiro (1 commits)")[![skwashd](https://avatars.githubusercontent.com/u/45939?v=4)](https://github.com/skwashd "skwashd (1 commits)")

---

Tags

hydratescaffoldplaceholderreplacewildcardskel

### Embed Badge

![Health badge](/badges/jkribeiro-composer-hydration/health.svg)

```
[![Health](https://phpackages.com/badges/jkribeiro-composer-hydration/health.svg)](https://phpackages.com/packages/jkribeiro-composer-hydration)
```

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k378.1M441](/packages/symfony-var-exporter)[dflydev/placeholder-resolver

Given a data source representing key =&gt; value pairs, resolve placeholders like ${foo.bar} to the value associated with the 'foo.bar' key in the data source.

14414.6M3](/packages/dflydev-placeholder-resolver)[laralib/l5scaffold

Extend Laravel 5's generators scaffold.

31474.1k](/packages/laralib-l5scaffold)[summerblue/generator

Extend Laravel's generators scaffold.

34139.9k](/packages/summerblue-generator)[incoming/incoming

Transform loose and complex input into consistent, strongly-typed data structures

21986.9k](/packages/incoming-incoming)

PHPackages © 2026

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