Download the PHP package biurad/consolelite without Composer
On this page you can find all versions of the php package biurad/consolelite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download biurad/consolelite
More information about biurad/consolelite
Files in biurad/consolelite
Package consolelite
Short Description This is the light weight version of Symfony Console
License MIT
Informations about the package consolelite
This library was strongly inspired by Symfony Console
Console Lite - BiuradPHP Toolbox
This is the light weight version of Symfony Console. @author Divine Niiquaye.
The Console tool allows you to create command-line commands. Your console commands can be used for any recurring task, stub generator, phar compile, such as cronjobs, imports, or other batch jobs.
Installation
Just run this composer command:
Quickstart
Creating a Console Application
First, you need to create a PHP script to define the console application:
Console Lite has a totally different approach in building console commands, not similar to Symfony Console but similar to Laravel Artisan. This was done in order to make it light weight.
You can register the commands using two different ways:
- php
!/usr/bin/env php
The compile
command has options for two kinds of input, thus the pack and unpack. Given them different config settings in clite.json.
If you already know the Phar class in php. you can finish up the steps by settings them up in clite.json. The phar packs or reads directories and files from your working directory.
The pack input after command compile
generate a phar file using the clite.json or using the options below.
-
--signature -> Set the signing signature of the phar. eg openssl.key.
-
--index -> Set the main file were the phar will be looaded from.
-
--compression -> Set the compression level for the phar. eg 0 or 4096.
-
--directory -> Set the directory where the phar is generated from.
-
--version -> Set the version of the project, so you stay up to date.
-
--bin -> Set the bin to be added to the compiled phar file.
-
--files -> Add the files that will be needed example, LICENSE file.
-
--excludes -> Add the excluded files or directories from the compiled phar file.
-
--type -> Set the type of phar that should be generated cli or web.
- --autoload -> Add the file which contains all the classes and namespaces for autoloading.
The unpack input after the command compile
extracts exverything containing in the phar file, into a directory reading from the clite.json or
using the options.
-
--files -> List the files that will be needed example, LICENSE file.(optional)
-
--extract -> Set the folder where the files and directories in phar will be extracted to.
- --overwrite -> Allow the previous extracted folders to be overwritten.
Stuble
Stuble is command line tool built with PHP to simplify working with stubs. Stuble will collect parameters in your stub(s) file(s) and ask you those parameters. So you don't need to write scripts to handle each stub file.
This is a class that simple let's you generate a class or php file out of a template. This is an abstract class, so you don't need to use it like phar, but use it to create a stub.
For usuage, extends the your stuble class to StubleGenerator
.
The StubleGenerator has a similarity to Laravel GeneratorCommand
, cause part of the class is from Laravel, but made simple. Check the class to find out.
When working with ConsoleLite Stuble, you don't need to input a destination path. Path deternation are generated from your namespaces and then the class in inserted into the the namespaces folders, starting from your working directory.
This code below is an example of how to implement a stuble.
and the template file which was saved in .stub
file extention, looks like the one below
PSR-3 Logging
The CLI class is a fully PSR-3 compatible logger (printing colored log data to STDOUT and STDERR). This is useful when you call backend code from your CLI that expects a Logger instance to produce any sensible status output while running.
By default the logger functions are written in Command
class.
To use this ability simply inherit from BiuradPHP\Toolbox\ConsoleLite\PSR3
instead of BiuradPHP\Toolbox\ConsoleLite\Command
, then pass $this
as the logger instance. Be sure you have the suggested psr/log
composer package installed.
License
- MIT
- Divine Niiquaye