Download the PHP package proximify/cli-actions without Composer

On this page you can find all versions of the php package proximify/cli-actions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cli-actions

CLI Actions

Command-line interface (CLI) with custom actions and interactive prompts (e.g. composer app:action argument).

Objective

The standard composer.json file allows for the declaration of CLI scripts. The scripts can then be called from the terminal. For example,

calls the static method action-name of a PHP script registered in the composer.json.

The procedure to declare the custom Composer scripts is simple but a bit repetitive. CLI Actions simplifies that process and adds functionality to create rich interactive CLI behaviors that are defined in JSON setting files.

Getting started

Add the CLI Actions to your project.

Then, add the scripts that you want to enable from the CLI.

In your project's composer.json, add

All actions can map to the same "auto" method of CLI Actions. That is one way in which CLI Actions simplifies the declaration of custom scripts.

The next step is to define what script to run and with what parameters. The arguments to a script can also be provided via the CLI and/or by prompting the user for them. The prompter checks what arguments were given in the CLI and only prompts the user for the missing ones.

The action definitions are JSON files that define the prompts for each argument and the acceptable values for them. In addition, the arguments can require sub-arguments based on the options selected for them. CLI Actions allows for nested definitions of arguments and sub-arguments.

The actions and their parameters are defined in JSON files. By default, the files in a root-level settings/cli folder are considered. The name of the file must match the name of the action. Each file defines a possible CLI action and their arguments.

Action definition object

Option definition

The options of an action argument can be can defined in terms of an option definition object with Key/Value pairs representing a map from a sub-action name to a nested sub-action defined inline or in another file:

  1. Inline - An object with a nested action definition;
  2. External - The boolean true is interpreted as a nested sub-action defined in another file located at config/cli-actions/MAIN-ACTION/SUB-ACTION/.../SUB-ACTION.

Additional Properties

In addition to action definition properties, an option definition allows for the following properties:

Example action definition

Creating a CLI for your Composer packages

Let's say you have a compose package named Publisher and you want to create a CLI for it. To do that, you have to create a class that extends the CLIActions. Let's call it, PublisherCLI. The only task of that class is to define the folders where the actions definitions are located.

That's it!

The action folder of ancestor classes are added recursively. That is, if the example PublisherCLI class extends another class that also has CLI actions, both paths return will be considered when searching for actions. Child paths are considered before parent paths.

In your project's composer.json use your own CLI class

By using your class, you will be adding your own action definitions and that of the ancestor classes of your class.

Action namespaces

It is recommended to use namespaces when defining actions. In the command line, an action namespace is given in the form A:B, where A is the namespace and B is the action name. The namespaces are evaluated as sub-folders. For example, if the command is

CLI Actions will try to load a settings file named update.json in a parent folder named app. By default, that would be the path settings\cli\app\update.json.

Using action namespaces is recommended in order to avoid collisions with standard composer actions, such as update and install.

The Composer event object

When a CLI Actions method is called as a result of a Composer event, a Composer\Script\Event object is provided as argument to the script callbacks defined in the composer.json file.

In some situations, the event object is needed by the action callbacks, so it is passed to them as an environment property named event. The event object can be used to obtain the Composer app object as well as information about the project.

Pre-stored extra arguments

The schema of a composer.json file allows for a special extra property.

extra: Arbitrary extra data for consumption by scripts.

CLI Actions automatically sets \$env['extra'] to the extra property of composer.json.

The extra property in composer.json can be used to set default values for arguments or to provide additional arguments that are constant for a given project.

Action methods

In addition to action definitions provided via JSON files, it is possible to defined custom methods directly by extending the CLIActions class. The method can be declared by name in composer.json. For example, assuming that PublisherCLI extends CLIActions, a methodName can be given as an action callback by:

The existence of the public method methodName is checked first and, only if it doesn't exist, a JSON action file is evaluated.

Standard Composer Events

Composer dispatches several named events during its execution process. All callbacks for all those events can be defined in by JSON action files named as the event the represent.

For example, to defined an action for the post-create-project-cmd, which occurs after the create-project command has been executed, simple create a JSON file named post-create-project-cmd.json and set the script callback for the event in the composer.json file.

In composer.json

In settings/cli/post-create-project-cmd.json

Example projects

Projects using CLI Actions.


Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to and actually do, grant us the rights to use your contribution. For details, visit our Contributor License Agreement.

When you submit a pull request, we will determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided. You will only need to do this once across all repos using our CLA.

This project has adopted the Proximify Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

Copyright (c) Proximify Inc. All rights reserved.

Licensed under the MIT license.

CLI Actions is made by Proximify. We invite the community to participate.


All versions of cli-actions with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
symfony/yaml Version ^5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package proximify/cli-actions contains the following files

Loading the files please wait ....