Download the PHP package jascha030/cli without Composer

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

PHP CLI service

Interface and implementation of a CLI Service class for executing shell commands with php, using symfony/process and symfony/console, heavily inspired by the CommandLine class from laravel/valet.

Getting Started

Requirements

Installation

Usage

The package contents consist mostly of one simple service class implementing an interface. Next to that there are also some derivatives of these classes and interfaces.

ShellInterface

The main interface is the Jascha030\CLI\Shell\ShellInterface, which requires a class to implement four methods.

Default Implementation

This package also provides class as most-basic implementation of the Jascha030\CLI\Shell\ShellInterface, The Jascha030\CLI\Shell\Shell class. This class implements all four methods.

All four methods use the Shell::runCommand method, which is also directly available.

Below is a simple example of basic usage of the class

The above outputs the following

Note: this example output is specific to your environment, the specific version and extensions are, of-course dependent on your own environment.

Execute a command silently

Executing commands as sudo user

All the methods, demonstrated above take the optional $cwd (string) and $onError (callable) parameters.

The $cwd command, allows you to execute a command from another directory.

The $onError is a callback that can be passed to handle command failure.

Both these parameters are directly passed to the Process::fromShellCommandline() method, for more info, refer to the documentation of symfony's Process component.

Shell program binaries

If you are writing a CLI based around a commandline program which comes as executable binary, you can implement the Jascha030\CLI\Shell\Binary\BinaryInterface. These are just extensions on the ShellInterface, requiring you to provide a name, a version, and a path to the binary.

To kickstart implementation, various Traits are available, together with an abstract class:

Helpers

A set of helper functions is included in includes/helper.php under the Jascha030\Cli\Helpers namespace.

Get user, or sudo user when available.

\Jascha030\CLI\Helpers\user(): ?string;

Output a message to the console.

\Jascha030\CLI\Helpers\output(string $message, ?OutputInterface $output = null): void;

Output an error to the console.

\Jascha030\CLI\Helpers\error(string $message, ?OutputInterface $output = null): void;

Output an info message to the console.

\Jascha030\CLI\Helpers\info(string $message, ?OutputInterface $output = null): void;

Output a multiline message to the console.

\Jascha030\CLI\Helpers\multilineOutput(array $message, ?OutputInterface $output = null): void;

Output a multiline error to the console.

\Jascha030\CLI\Helpers\multilineError(array $message, ?OutputInterface $output = null): void;

Output a multiline info message to the console.

\Jascha030\CLI\Helpers\multilineInfo(array $message, ?OutputInterface $output = null): void;

Development

Clone this repo, and run composer install inside the repo.

Code-style

A code-style is provided in the form of a php-cs-fixer configuration in .php-cs-fixer.dist.php. For easy execution, use the provided Composer script command.

If you have php-cs-fixer installed globally, pass it to the --config argument of the fix command.

Unit-testing

A configuration for phpunit is provided in phpunit.xml.

For easy execution, use the provided Composer script command.

If you have phpunit installed globally, and want to use that, pass the config in the --config argument.

of the CommandLine class of the laravel/valet package.

Next to that, it obviously makes heavy use of various Symfony components, which makes your life as a php-developer a lot easier in many cases. For one, by not having to re-invent the wheel. And also, the usage of Symfony components, in almost every case guarantees, at least some level of interoperability with most other php frameworks, libraries and of-course composer.

License

This composer package is an open-sourced software licensed under the MIT License


All versions of cli with dependencies

PHP Build Version
Package Version
Requires symfony/process Version ^6.0
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 jascha030/cli contains the following files

Loading the files please wait ....