Download the PHP package asika/symfony-console-completion without Composer

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

BASH/ZSH auto-complete for Symfony Console applications (Fork for Symfony6)

This package provides automatic (tab) completion in BASH and ZSH for Symfony Console Component based applications. With zero configuration, this package allows completion of available command names and the options they provide. User code can define custom completion behaviour for argument and option values.

Example of zero-config use with Composer:

Composer BASH completion

Zero-config use

If you don't need any custom completion behaviour, you can simply add the completion command to your application:

  1. Install stecman/symfony-console-completion using composer by running:

  2. For standalone Symfony Console applications, add an instance of CompletionCommand to your application's Application::getDefaultCommands() method:

    For Symfony Framework applications, register the CompletionCommand as a service in app/config/services.yml:

  3. Register completion for your application by running one of the following in a terminal, replacing [program] with the command you use to run your application (eg. 'composer'):

    By default this registers completion for the absolute path to you application, which will work if the program is accessible on your PATH. You can specify a program name to complete for instead using the --program option, which is required if you're using an alias to run the program.

  4. If you want the completion to apply automatically for all new shell sessions, add the command from step 3 to your shell's profile (eg. ~/.bash_profile or ~/.zshrc)

Note: The type of shell (ZSH/BASH) is automatically detected using the SHELL environment variable at run time. In some circumstances, you may need to explicitly specify the shell type with the --shell-type option.

How it works

The --generate-hook option of CompletionCommand generates a small shell script that registers a function with your shell's completion system to act as a bridge between the shell and the completion command in your application. When you request completion for your program (by pressing tab with your program name as the first word on the command line), the bridge function is run; passing the current command line contents and cursor position to [program] _completion, and feeding the resulting output back to the shell.

Defining value completions

By default, no completion results will be returned for option and argument values. There are two ways of defining custom completion values for values: extend CompletionCommand, or implement CompletionAwareInterface.

Implementing CompletionAwareInterface

CompletionAwareInterface allows a command to be responsible for completing its own option and argument values. When completion is run with a command name specified (eg. myapp mycommand ...) and the named command implements this interface, the appropriate interface method is called automatically:

This method of generating completions doesn't support use of CompletionInterface implementations at the moment, which make it easy to share completion behaviour between commands. To use this functionality, you'll need write your value completions by extending CompletionCommand.

Extending CompletionCommand

Argument and option value completions can also be defined by extending CompletionCommand and overriding the configureCompletion method:

The Completion class

The following snippets demonstrate how the Completion class works with CompletionHandler, and some possible configurations. The examples are for an application with the signature:

`myapp (walk|run) [-w|--weather=""] direction`
Command-specific argument completion with an array

This will complete the direction argument for this:

but not this:

Non-command-specific (global) argument completion with a function

This will complete the direction argument for both commands:

Option completion

Option handlers work the same way as argument handlers, except you use Completion::TYPE_OPTION for the type.

Completing the for both arguments and options

To have a completion run for both options and arguments matching the specified name, you can use the type Completion::ALL_TYPES. Combining this with Completion::ALL_COMMANDS and consistent option/argument naming throughout your application, it's easy to share completion behaviour between commands, options and arguments:

Example completions

Completing references from a Git repository

Completing filesystem paths

This library provides the completion implementation ShellPathCompletion which defers path completion to the shell's built-in path completion behaviour rather than implementing it in PHP, so that users get the path completion behaviour they expect from their shell.

Behaviour notes


All versions of symfony-console-completion with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.2
symfony/console Version ~6.0
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 asika/symfony-console-completion contains the following files

Loading the files please wait ....