Download the PHP package spaceboy/nette-cli without Composer

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

NetteCli

Simple tool for easy CLI apps creation in Nette framework

Installation

The best way to install into Nette web application is the easiest one. Open console, go to your app directory and execute following command:

My first CLI application

I strongly recommend you to create a dedicated space for CLI applications in app root directory. For example bin for apps operated from command line and cron for apps runned from cron.

After installation copy (or link) file nette-cli.php from vendor/spaceboy/nette-cli/bin directory to folder dedicated for CLI scripts (e.g. bin).

Create a PHP file, f.e. command.php in bin directory:

Or create template script by simple running nette-cli.php in bin directory:

In command.php, we at first must create app namespace and include required files and namespaces.

Then we can create our first app:

That's all, folks. Try it in command line:

As we've registered command named "hello", it's worker function is called and executed.

As we've registered argument named "name" and set that argument required for command "hello" (Command->withArgumentRequired([arg-name])), our app will not run without typing argument in command line.

As we've registered also shortcut argument name (Argument->setShortcut()), we can run our app wit less writing:

As we've set required format of argument "name" (Argument->setFormat()) as string:2..25 (string with length at least 2 chars and 25 chars max), our app will not run with too short or too long name. Try it yourself.

As we've registered also option named "strong" in application (Cli->registerOption('strong')) and enabled this option in command "hello" (Command->withOption(strong)), we can use it:

Cli public methods:

Argument public methods:

Command public methods:

Class Format

Class Format is an simple helper for easier command line text formatting.

Methods:

Color table:

text color code background color code color
DEFAULT_COLOR BG_DEFAULT default console color
BLACK BG_BLACK black
RED BG_RED red
GREEN BG_GREEN green
YELLOW BG_YELLOW yellow
BLUE BG_BLUE blue
MAGENTA BG_MAGENTA magenta
CYAN BG_CYAN cyan
LIGHT_GRAY BG_LIGHT_GRAY light gray
DARK_GRAY BG_DARK_GRAY dark gray
LIGHT_RED BG_LIGHT_RED light red
LIGHT_GREEN BG_LIGHT_GREEN light green
LIGHT_YELLOW BG_LIGHT_YELLOW light yellow
LIGHT_BLUE BG_LIGHT_BLUE light blue
LIGHT_MAGENTA BG_LIGHT_MAGENTA light magenta
LIGHT_CYAN BG_LIGHT_CYAN light cyan
WHITE BG_WHITE white

Using helpers

When things gonna be complicated, you should need to share some argument(s) or worker functions(s) between two or more scripts (e.g. between cli script and cron script). Feel free to use helpers. You can set both static and dynamic methods as command worker function as well as closure. Just don't forget that those methods must be public.


All versions of nette-cli with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
nette/bootstrap Version ^3.0
nette/utils Version ^3.0
nette/di Version ^3.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 spaceboy/nette-cli contains the following files

Loading the files please wait ....