PHPackages                             roaresearch/composer-utils - 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. roaresearch/composer-utils

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

roaresearch/composer-utils
==========================

Classes that helps using composer on libraries and projects

1.0.0(3y ago)01903BSD-3-ClausePHPPHP ~8.1

Since Aug 17Pushed 3y ago2 watchersCompare

[ Source](https://github.com/ROAResearch/composer-utils)[ Packagist](https://packagist.org/packages/roaresearch/composer-utils)[ Docs](https://github.com/ROAResearch/composer-utils)[ RSS](/packages/roaresearch-composer-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (3)

Composer Install Utils
======================

[](#composer-install-utils)

Utils to automatically configure and bootstrap the installation of a project or library using composer.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

add

```
"roaresearch/composer-utils": "~1.0.0"
```

to the require section of your composer.json for projects or the require-dev section for libraries.

```
That means its important that a library doesnt inherit
this dependency but projects that are meant to be used on production and are
not going to be inherited can use this library as part of their installation
bootstrap process.

```

Usage
-----

[](#usage)

To utilize this library first the concept of "builder" and "template" needs to be explained.

A "builder" is a composer script that gets information from the developer or environment to build a series of templates.

The "templates" are files that will be generated when the project is created or the builder is manually called. These files will contain information to bootstrap the project or library.

As such the composer.json file needs to include a call for the builder and a configuration for the templates.

```
    "scripts": {
        "bootstrap-install": "roaresearch\\composer\\utils\\DBListener::config",
        "blank-install": "roaresearch\\composer\\utils\\DBListener::blankConfig",
        "post-create-project-cmd": "@bootstrap-install"
    },
    "extra": {
        "utilConfig": {
            "dbname": "cool_project",
            "dbtestsuffix": "_test",
            "dbtpls": {
                "db.local.php": "roaresearch\\composer\\utils\\VarDBTPL"
            }
            "dbtesttpls": {
                "db.test.php": "roaresearch\\composer\\utils\\VarDBTPL"
            }
        }
    },
```

This creates scripts bootstraps-install and blank-install then calls bootstrap-install after creating a new project with this library.

If bootstrap-install is called then it will ask for the db credentials, check those credentials works, that the database exists and will create a config file db.local.php using the template VarDBTPL.

If blank-install is called then it will ask for the db credentials but wont make any check or validation about it and will simply create the config file with the provided credentials.

In the above case dbtestsuffix is configured aswell which means a database meant purely for testing will be created by adding the suffix to the databse name. In this case the testing databse will be `cool_project_test` and the respective config file db.test.php

If dbtestsuffix is not set or if an argument "environment" is set to "prod" the test database and config file wont be created. For more info on parameters check the following section.

Notice that the tpl file routes are relative to the root folder of the project composer installation, subfolders are allowed but no parents folders or absolute routes.

### Arguments

[](#arguments)

Arguments are the information that the builders need to fill the templates.

Arguments can be obtained by 3 main ways which are detailed in the order they are processed.

#### Command Arguments

[](#command-arguments)

This arguments are only used when the builders are called manually and not by getting called after creating a project.

The arguments are written on the console as `arg=value`.

Using the composer.json from the example above as reference

```
composer create-project coolcompany/coolproject web/ --no-scripts
cd web/
composer bootstrap-install -- dbname=prod_project dbuser=root dbpass=s3cr3t
```

#### Package Arguments

[](#package-arguments)

This arguments are configured on the composer.json file on the extra.utilConfig section. On the example above only dbname is configured this way since its expected that dbuser, dbpass and dbdsn will change every time the project is cloned on a new environment but all arguments can be set on the composer.json in case your company or development team have standarized users and passwords.

To use them just call the create-project command or the script manually

#### Environment Arguments

[](#environment-arguments)

PHP supports environmental variables in server but also on console which doesnt affect the server handling the actual requests.

As such its safe to use environment variables during the bootstrap install.

```
export dbuser="root"
export dbpass="s3cr3t"
composer create-project coolcompany/coolproject web/
composer create-project coolcompany/anotherproject web2/
```

The create-project command will create config files for both projects using the environment variables this way. It also helps when determining if a server is meant for production or development by using the "environment" argument. Yes its redundant on purpose.

```
export environment="prod"
```

or

```
export environment="dev"
```

#### Prompt Arguments

[](#prompt-arguments)

Finally if an argument is not set but the builder needs it then the console will prompt the user to write it on a prompt. If the variable has a default value to use when receiving an empty response then that default value will appear on the prompt between parenthesis.

Supported Arguments
-------------------

[](#supported-arguments)

roaresearch\\composer\\utils\\DBListener::config and roaresearch\\composer\\utils\\DBListener::blankConfig support the same arguments with the difference that comfig will corroborate the given credentials while blankConfig wont.

- dbuser
- dbpass
- dbname
- dbdsn
- dbtestsuffix
- environment

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

1368d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2341d88f3cdea0c2474cfbf59e5cf6dab5dd6a026d7846fabf219f2a93be1641?d=identicon)[neverabe](/maintainers/neverabe)

---

Top Contributors

[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (4 commits)")[![neverabe](https://avatars.githubusercontent.com/u/1173807?v=4)](https://github.com/neverabe "neverabe (1 commits)")

---

Tags

composer

### Embed Badge

![Health badge](/badges/roaresearch-composer-utils/health.svg)

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

###  Alternatives

[jean85/pretty-package-versions

A library to get pretty versions strings of installed dependencies

1.3k289.5M63](/packages/jean85-pretty-package-versions)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[icanhazstring/composer-unused

Show unused packages by scanning your code

1.7k7.0M188](/packages/icanhazstring-composer-unused)[bamarni/composer-bin-plugin

No conflicts for your bin dependencies

52722.0M859](/packages/bamarni-composer-bin-plugin)[composer/metadata-minifier

Small utility library that handles metadata minification and expansion.

181115.0M13](/packages/composer-metadata-minifier)[shipmonk/composer-dependency-analyser

Fast detection of composer dependency issues (dead dependencies, shadow dependencies, misplaced dependencies)

6076.7M435](/packages/shipmonk-composer-dependency-analyser)

PHPackages © 2026

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