Download the PHP package zenstruck/console-extra without Composer

On this page you can find all versions of the php package zenstruck/console-extra. 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 console-extra

zenstruck/console-extra

CI codecov

A modular set of features to reduce configuration boilerplate for your Symfony commands:

Installation

Usage

This library is a set of modular features that can be used separately or in combination.

[!NOTE] To reduce command boilerplate even further, it is recommended to create an abstract base command for your app that enables all the features you desire. Then have all your app's commands extend this.

IO

This is a helper object that extends SymfonyStyle and implements InputInterface (so it implements InputInterface, OutputInterface, and StyleInterface).

On its own, it isn't very special, but it can be auto-injected into Invokable commands.

InvokableCommand

Extend this class to remove the need for extending Command::execute() and just inject what your need into your command's __invoke() method. The following are parameters that can be auto-injected:

You can auto-inject the "raw" input/output:

No return type (or void) implies a 0 status code. You can return an integer if you want to change this:

InvokableServiceCommand

If using the Symfony Framework, you can take InvokableCommand to the next level by auto-injecting services into __invoke(). This allows your commands to behave like Invokable Service Controllers (with controller.service_arguments). Instead of a Request, you inject IO.

Have your commands extend InvokableServiceCommand and ensure they are auto-wired/configured.

Inject with DI Attributes

You can use any DI attribute on your __invoke() parameters:

Configure with Attributes

Your commands that extend InvokableServiceCommand can configure arguments and options with attributes:

Invokable Attributes

Instead of defining at the class level, you can add the Option/Argument attributes directly to your __invoke() parameters to define and inject arguments/options:

[!NOTE] Option/Argument modes and defaults are detected from the parameter's type-hint/default value and cannot be defined on the attribute.

CommandRunner

A CommandRunner object is available to simplify running commands anywhere (ie controller):

If the application is available, you can use it to run commands:

If your command is interactive, you can pass inputs:

By default, output is suppressed, you can optionally capture the output:

RunsCommands

You can give your Invokable Commands the ability to run other commands (defined in the application) by using the RunsCommands trait. These sub-commands will use the same output as the parent command.

RunsProcesses

You can give your Invokable Commands the ability to run other processes (symfony/process required) by using the RunsProcesses trait. Standard output from the process is hidden by default but can be shown by passing -v to the parent command. Error output is always shown. If the process fails, a \RuntimeException is thrown.

CommandSummarySubscriber

Add this event subscriber to your Application's event dispatcher to display a summary after every command is run. The summary includes the duration of the command and peak memory usage.

If using Symfony, configure it as a service to enable:

[!NOTE] This will display a summary after every registered command runs.


All versions of console-extra with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/console Version ^6.4|^7.0
symfony/deprecation-contracts Version ^2.2|^3.0
zenstruck/callback Version ^1.4.2
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 zenstruck/console-extra contains the following files

Loading the files please wait ....