liberty_code / command
Library
Requires
- php: ~7 || ~8
- liberty_code/authentication: ^1.0.
- liberty_code/library: ^1.0.
- liberty_code/request_flow: ^1.0.
- liberty_code/route: ^1.0.
Requires (Dev)
- liberty_code/di: ^1.0.
- liberty_code/register: ^1.0.
This package is auto-updated.
Last update: 2025-02-11 04:45:31 UTC
README
Description
Library contains command line components, to use features and other libraries components, on command line context.
Requirement
- Script language: PHP: version 7 || 8
Installation
Several ways are possible:
Composer
Requirement
It requires composer installation. For more information: https://getcomposer.org
Command: Move in project root path
cd "<project_root_path>"
Command: Installation
php composer.phar require liberty_code/command ["<version>"]
Note
Include vendor
If project uses composer, vendor must be included:
require_once('<project_root_path>/vendor/autoload.php');
Configuration
Installation command allows to add, on composer file "
{ "require": { "liberty_code/command": "<version>" } }
Include
Download
- Download following repository.
- Put it on repository root path.
Include source
require_once('<repository_root_path>/include/Include.php');
Configuration
Main configuration
Use following class to configure specific elements
use liberty_code\command\config\model\DefaultConfig; DefaultConfig::instanceGetDefault()->get|set...();
Elements configurables
- Request options
Usage
Route
Route allows to interpret specified source, from command line request, on command line context, to get executable.
Elements
CommandPatternRoute, CommandParamRoute, CommandFixRoute, CommandSeparatorRoute
Extends route features. Adapt all standard routes, to interpret specified source, from command line request, and get information (summary and help).
CommandRouteFactory
Extends DI route factory features. Provides command route instance.
Request
Request allows to provide route source, on request flow process and command line context.
Elements
CommandRequest
Extends request features. Allows to design command line request.
Example
use liberty_code\command\request_flow\request\model\CommandRequest;
$request = CommandRequest::instanceGetDefault();
echo($request->getStrRouteSrc());
// Show "{route:<route>,argument:[<command line arguments...>],option:[<command line options...>]}"
...
Response
Response allows to provide final send-able content, from request flow process, on command line context.
Elements
Response utilities
Information command line response allows to get specific information about context, on command line context.
Example: response with command lines summary content, response with specific command line help content.
Front controller
Front controller allows to design the request flow process, on command line context.
Elements
CommandFrontController
Extends front controller features. Uses command line request, to get response.
InfoFrontController
Extends command line front controller features. Allows to manage information command line responses.
Example
use liberty_code\command\request_flow\front\model\CommandFrontController;
$frontController = new CommandFrontController();
$frontController->setRouter(...);
$frontController->setActiveRequest(...);
...
// Show response object
var_dump($frontController->execute());
...
Authentication
Authentication allows to design an authentication class, using command request arguments.
Elements
CommandAuthentication
Extends authentication features. Uses command request arguments, to get all identification and authentication information.
Example
// Get command authentication
use liberty_code\command\request_flow\request\model\CommandRequest;
$commandAuth = new CommandRequest($request);
$commandAuth->setAuthConfig(...);
...
// Get array of identification data
var_dump($commandAuth->getTabIdData());
...
// Get array of authentication data
var_dump($commandAuth->getTabAuthData());
...