New PHP-Prefixer CLI: Prefix from the Terminal

Are you tired of using our website to upload and prefix projects? Are you tired of not being able to script prefixing operations into your development pipeline easily?

After the recent release of the REST API and the upcoming GitHub Action, we introduce the PHP-Prefixer Command-Line (CLI).

To easily script PHP-Prefixer into your development pipeline, the CLI allows simple access from the command line to the functionality provided by the PHP-Prefixer.

Here is a snippet for the main operation:

# Sample command line
#
# The arguments are:
#     1. The project source directory.
#     2. The target directory to store the results.
#     3. The PHP-Prefixer personal access token.
#     4. The PHP-Prefixer/ Project ID.
#     5. Optionally, a GitHub token to access token.
#
php-prefixer-cli prefix \
    /sample/acme_project \
    /output/prefixed_project \
    789|1234567890123456789012345678901234567890 \
    123456 \
    --github-access-token=1234567890123456789012...

To run the command, you must configure the personal access token (Settings / Personal Access Tokens) and the project ID on PHP-Prefixer. If you want to include a GitHub token, you can generate it by following the steps mentioned in Creating a personal access token.

How to install the CLI?

You can install the CLI using two ways:

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. After downloading it, copy the file into a directory on your local path.

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: https://github.com/PHP-Prefixer/php-prefixer-cli

It’s quick and easy to get a project up and running. The PHP-Prefixer CLI supports the same use cases that you can find in our guides. You can find the complete CLI reference in the Command Line Documentation.

If you find a bug or have a feature request, get in touch with me here. Follow us on Twitter.

Photo by Kevin Ku on Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.