PHPackages                             php-prefixer/php-prefixer-cli - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. php-prefixer/php-prefixer-cli

ActiveProject[HTTP &amp; Networking](/categories/http)

php-prefixer/php-prefixer-cli
=============================

A command-line for the PHP-Prefixer service.

0.0.7(3y ago)1501MITPHPPHP ^7.3 || ^8.0

Since May 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/PHP-Prefixer/php-prefixer-cli)[ Packagist](https://packagist.org/packages/php-prefixer/php-prefixer-cli)[ Docs](http://php-prefixer.com/)[ RSS](/packages/php-prefixer-php-prefixer-cli/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (7)Dependencies (9)Versions (8)Used By (0)

PHP Prefixer CLI
================

[](#php-prefixer-cli)

[![PHP-Prefixer](https://camo.githubusercontent.com/7ba72633968fa4b639ff603d259b51866c97408eba84eb5644d82e7d7def1d6a/68747470733a2f2f7068702d70726566697865722e636f6d2f696d616765732f6c6f676f2f7068702d70726566697865722d313434783134342e706e67)](https://camo.githubusercontent.com/7ba72633968fa4b639ff603d259b51866c97408eba84eb5644d82e7d7def1d6a/68747470733a2f2f7068702d70726566697865722e636f6d2f696d616765732f6c6f676f2f7068702d70726566697865722d313434783134342e706e67)

[![MIT License](https://camo.githubusercontent.com/7c124530b7c185c6928998842a1a52ed4bfd21071bf67db8f325f470cc3160a3/68747470733a2f2f696d672e736869656c64732e696f2f61706d2f6c2f61746f6d69632d64657369676e2d75692e7376673f)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)

A command-line for the [PHP-Prefixer](https://php-prefixer.com) service.

**Blog post announcement**: [New PHP-Prefixer CLI: Prefix from the Terminal](https://blog.php-prefixer.com/2021/06/12/new-php-prefixer-cli-prefix-from-the-terminal/)

The [PHP-Prefixer](https://php-prefixer.com) service has a command-line (CLI) to use the service locally and process the project source code from your workstation.

The command calls the **PHP-Prefixer** service using the [REST API](https://php-prefixer.com/docs/rest-api-reference/) to submit a project source code, apply the prefixes, wait and download the results.

**PHP-Prefixer** is a cloud service to apply PHP prefixes to namespaces, functions, helpers, traits, interfaces, etc. Start with a Composer project and a set of dependencies, and prefix all library files at once to generate a consistent prefixed codebase.

Given this sample class declaration:

```
namespace Carbon;

use Carbon\Exceptions\InvalidDateException;
use DateInterval;
use Symfony\Component\Translation;

class Carbon extends DateTime
{
    const NO_ZERO_DIFF = 01;
...
```

The associated prefixed class declaration, with a new and distinct namespace `ACME`:

```
namespace ACME\Carbon;

use ACME\Carbon\Exceptions\InvalidDateException;
use DateInterval;
use ACME\Symfony\Component\Translation;

class Carbon extends DateTime
{
    const NO_ZERO_DIFF = 01;
...
```

How to install the CLI?
-----------------------

[](#how-to-install-the-cli)

You can install the CLI using two ways:

### 1. How to install the PHAR CLI

[](#1-how-to-install-the-phar-cli)

The preferred installation method is with the **PHP Prefixer CLI PHAR**. You can download the latest PHAR from the most recent [Github Releases](https://github.com/PHP-Prefixer/php-prefixer-cli/releases). After downloading it, copy the file into a directory on your local path and assign the execution permissions to run the following commands.

### 2. Install via Composer

[](#2-install-via-composer)

Alternatively, you can install **PHP-Prefixer CLI** globally with Composer:

```
composer global require php-prefixer/php-prefixer-cli
```

The source code is available here:

Usage
-----

[](#usage)

To use the CLI, you must create an account on [PHP-Prefixer](https://php-prefixer.com/) and prepare your projects with the prefix definition in the `composer.json` schema.

Before using the command-line, we recommend checking the documentation and guides here:

The CLI requires four parameters to function, and it can receive an additional parameter for GitHub integration:

ParameterDescriptionsource-directory \*The project source directorytarget-directory \*The target directory where the results are storedpersonal-access-token\*The personal access token, generated on [PHP-Prefixer](https://php-prefixer.com/) Settingsproject-id \*The identification of the configured project on [PHP-Prefixer](https://php-prefixer.com/) Projects--github-access-tokenAn optional GitHub token to access ´composer.json´ dependencies that are managed in private repositories```
# Sample command-line
./php-prefixer-cli prefix \
\
    /sample/acme_project \
\
    /output/prefixed_project \
\
    "789|1234567890123456789012345678901234567890" \
\
    123456 \
\
    --github-access-token=1234567890123456789012345678901234567890
```

### Environment Variables

[](#environment-variables)

The CLI supports the definition of the parameters as environment variables in a project `.env` file.

```
# PHP Prefixer CLI - Sample .env

# Note: the .env file must be located in the php-prefixer-cli.phar directory

# Source Directory: The project source directory
SOURCE_DIRECTORY="/sample/acme_project"

# Target Directory: The target directory where the results are stored
TARGET_DIRECTORY="/output/prefixed_project"

# Personal Access Token: The personal access token, generated on PHP-Prefixer Settings
PERSONAL_ACCESS_TOKEN="789|1234567890123456789012345678901234567890"

# Project ID: The identification of the configured project on PHP-Prefixer Projects
PROJECT_ID="123456"

# GitHub Access Token:  An optional GitHub token to access composer.json dependencies that are managed in private repositories.
GITHUB_ACCESS_TOKEN="1234567890123456789012345678901234567890"
```

Documentation
-------------

[](#documentation)

- [PHP-Prefixer Documentation](https://php-prefixer.com/docs)
- [PHP Prefixer CLI](https://php-prefixer.com/docs/command-line)
- [REST API Reference](https://php-prefixer.com/docs/rest-api-reference/)

Command-Line Development
------------------------

[](#command-line-development)

If you want to customize the command-line or help us in the development, please, check the following steps:

Step 1: Clone the project:

```
git clone https://github.com/php-prefixer/php-prefixer-cli
```

Step 2: Go to the project directory:

```
cd php-prefixer-cli
```

Step 3: Install dependencies:

```
composer update
```

Step 4: Build the PHAR:

```
./php-prefixer-cli app:build
```

Step 5: To run tests, execute the following command:

```
phpunit
```

Roadmap / Ideas
---------------

[](#roadmap--ideas)

This roadmap is subject to change and should only be used as a general guideline regarding future releases. As long as a version, feature or application is not yet released, the dates are estimated and could be altered.

- Parameter to exclude directories from ZIP, `--exclude`

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

[](#contributing)

The current CLI is a starting point to prefix PHP code. If you want to improve the current commmand-line, contributions are always welcome!

See [CONTRIBUTING.md](https://github.com/PHP-Prefixer/php-prefixer-cli/blob/main/CONTRIBUTING.md) for ways to get started.

Security
--------

[](#security)

If you discover a security vulnerability within this package, please email to Anibal Sanchez at . We address all security vulnerabilities promptly.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

Authors
-------

[](#authors)

- [Aníbal Sánchez](https://www.twitter.com/anibal_sanchez)
- [PHP-Prefixer](https://php-prefixer.com/), Desarrollos Inteligentes Virtuales, SL.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Every ~92 days

Recently: every ~135 days

Total

7

Last Release

1262d ago

PHP version history (2 changes)0.0.1PHP ^7.3|^8.0

0.0.3PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/18617f0615e4b38790002703a908d75ca7a073fe63789c227ab5e543e8497f29?d=identicon)[php-prefixer](/maintainers/php-prefixer)

![](https://www.gravatar.com/avatar/df7fbcf5652e2a22940918d3c4db48cfaadd50c9096fd7ccd46504d62eb6fd07?d=identicon)[anibal.sanchez](/maintainers/anibal.sanchez)

---

Top Contributors

[![anibalsanchez](https://avatars.githubusercontent.com/u/385780?v=4)](https://github.com/anibalsanchez "anibalsanchez (45 commits)")

---

Tags

functionsnamespacenamespaces-phpphpphp-prefixerprefixphpclirestserviceprefixfunctionsnamespaceprefixerphp-prefixernamespaces-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/php-prefixer-php-prefixer-cli/health.svg)

```
[![Health](https://phpackages.com/badges/php-prefixer-php-prefixer-cli/health.svg)](https://phpackages.com/packages/php-prefixer-php-prefixer-cli)
```

###  Alternatives

[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client

Documentation for all of Ory Hydra's APIs.

17435.9k](/packages/ory-hydra-client)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1204.3k](/packages/zenditplatform-zendit-php-sdk)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

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