Download the PHP package bulton-fr/bfw-cli without Composer

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

bfw-cli

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version License

Module to use the BFW framework with basic cli script. A futur module will be created for an advanced usage of cli scripts.


Install

You can use composer to get the module : composer require bulton-fr/bfw-cli @stable

And to install the module : ./vendor/bin/bfwInstallModules

Config

There is no config file :smile:

Use it

After installed it, just use the cli.php script into you console.
Use the parameter -f to say what file into /src/cli to execute.
The parameters -f is mandatory for /cli.php script, but all cli script executed by him can also have their own parameters.

Note : We use the function getopt(), so take the time to understand how to pass parameters values.

Example

An example script is installed by default, you can use it to see how execute cli script.
To play the script, you should do :

Helper

An helper to sent message into the console is present.

To write a message, you can use methods displayMsg and displayMsgNL. The first write a message without a line break. The second adds a line break automatically at the end of the message.

Flush system

By default, when the framework is loaded, the function ob_start is called. Because of that, all output is sent into a buffer and displayed when application shutdown. To avoid that, you can force the buffer to display with the function ob_flush.

In cli, it can be useful to always display the buffer content when we write a message. But sometimes, we can prefer the message is not displayed right now.

To manage this two case, a flush system is integrated. By default the buffer is flushed at the end of methods displayMsg and displayMsgNL. But you can define to not flush and choose when you want to flush the buffer.

For doing that, there are :

It's the property value who defines if the flush will be automatically called or not. If the value is the constant FLUSH_AUTO, the flush will be done at the end of methods. But if the value is the constant FLUSH_MANUAL, the flush will never be done by the system; you should do it yourself.

Constants

Errors/Exception codes

These constants are sent when an exception is thrown and used like exception code.

__ERR_COLOR_NOT_AVAILABLE__

Exception code if the color is not available.

__ERR_STYLE_NOT_AVAILABLE__

Exception code if the style is not available.

Methods

To display a message

public static function displayMsg(string $msg, string $colorTxt = 'white', string $style = 'normal', string $colorBg = 'black')

public static function displayMsgNL(string $msg, string $colorTxt = 'white', string $style = 'normal', string $colorBg = 'black')

These two methods will display a message with color and/or style.

The first method will just display the message, the second will add a line break (\n) at the end of the message.

Arguments are :

If there is only the first argument, the color and style will not be defined and stay with shell configuration at this moment. And if there are only the first three arguments, the background-color will not be defined and stay with shell configuration at this moment.

To define color code to use in the shell

protected static function colorForShell(string $color, string $type): int

This method will return the color code to use in the shell for a string color name.

Available colors are :

If the color name into the argument not exist, an exception will be thrown. The exception code will be the constant \BfwCli\Helpers\Cli::ERR_COLOR_NOT_AVAILABLE.

The argument string $type is where the color code will be used. The value can be txt or bg.

It's to return the correct color code. To explain, each color has an integer value. But if the color is for the text color, the value should be between 30 and 39. And if the color is for the background color, the value should be between 40 and 49.

So we ask where the color will be used to return to the correct value range.

To define style code to use in the shell

protected static function styleForShell(string $style): int

This method will return the style code to use in the shell for a string style name.

Available styles are :

if the style name into the argument not exist, an exception will be thrown. The exception code will be the constant \BfwCli\Helpers\Cli::ERR_STYLE_NOT_AVAILABLE.


All versions of bfw-cli with dependencies

PHP Build Version
Package Version
Requires bulton-fr/bfw Version ~3.0.0-RC11@RC
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 bulton-fr/bfw-cli contains the following files

Loading the files please wait ....