Download the PHP package adeptoas/sweet-cli without Composer

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

SweetCLI

A framework for creating awesome CLI applications using PHP.

Installation

Add this to composer.json:

Make sure to merge your require-blocks!

Examples

For examples have a look in /example. There you'll find a step-by-step tutorial on how to create a CLI application.

Concept

Your CLI application will consist of the main entry point and your subcommands. Each subcommand can have options and arguments and is free to do whatever it needs to do. Commands look like this:

How to Build an Application

  1. Create a new file you want to use as your "binary" to be run. I recommend cli.
  2. Put this in the top of your file (nothing before it!):

  3. Include the composer autoloader:

  4. Subclass Adepto\SweetCLI\Base\CLIApplication and override these methods:
    • public static function getTitle(): string
    • public static function getShortTitle(): string
  5. Subclass Adepto\SweetCLI\Subcommands\SubCommand for every subcommand you need and override these methods:
    • public static function getOptions(): array (refer to the options syntax for this)
    • public static function getCommand(): string
    • public static function getDescription(): string
  6. Instantiate your application (where Application is the name of your class. If you used PHP anonymous classes you don't need this step.):

  7. Add your newly created subcommand classes to your application (do not create instances!):

  8. (Optional) Add aliases:

    Aliases are special subcommands that collect all passed arguments and call another application with those options, i.e. cli composer -v -> composer -v. The command will be run from the application's working directory, if a path was passed to the application's constructor.

  9. Call $app->run($argv).
  10. Make your script executable: chmod +x cli
  11. You can now run it: ./cli --help

Options Syntax

When creating a subcommand you have to override the getOptions(): array method. This has to return an array of available options for that subcommand. The key of each item has to be the option specification with the value being another array with modifiers.

This is the option specification:

So in short:

This is a list of available modifiers:

Usage

SubCommand

This is only a description of the public API that you will use to do stuff in your subcommand.

See if hasConflictingOptions() returns true and if so throw an exception.

Returns true if $bool occurs more than once in $values

See if this subcommand has been given options.

See if this subcommand has been given a specific $option.

Get the value of a specific option or null if the option wasn't set.

Set the value of an option. Use this with caution!

Require an option to be set and terminate with $message if missing.

Get the application the subcommand has been called from. If you have multiple applications using the same subcommand this can be handy to determine what to do based on the application.

Check if $option is set and throw an exception containing $message if it isn't set.


All versions of sweet-cli with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
corneltek/getoptionkit Version ^2.6.1
kevinlebrun/colors.php Version ^1.0.3
ext-mbstring Version *
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 adeptoas/sweet-cli contains the following files

Loading the files please wait ....