1. Go to this page and download the library: Download 00f100/fcphp-command library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
00f100 / fcphp-command example snippets
use FcPhp\SConsole\SCEntity;
use FcPhp\Command\Interfaces\ICEntity;
use FcPhp\Command\Facades\CommandFacade;
// Instance of SCEntity provider from FcPhp Security Console
// or ...
$entity = new SCEntity();
// Custom commands...
$commands = [];
// Composer dir to autoload find "commands.php" into packages and cache into FcPhp Cache
$vendorPathAutoload = 'vendor/*/*/config';
$instance = CommandFacade::getInstance($entity, $commands, $vendorPathAutoload);
// Args from console request
// Example: php index.php package datasource connect -h localhost -u user -p password
$args = [
'package',
'datasource',
'connect',
'-h',
'localhost',
'-u',
'user',
'-p',
'password'
];
// Return instance FcPhp\Command\Interfaces\ICEntity
$match = $this->instance->match($args);
if($match instanceof ICEntity) {
// Print status code
echo $match->getStatusCode();
// Print action
echo $match->getAction();
// ...
}
namespace FcPhp\Command\Interfaces
{
interface ICEntity
{
/**
* Method to contruct instance
*
* @param array $params Params to entity
* @return void
*/
public function __construct(array $params = []);
/**
* Method to get command
*
* @return string|null
*/
public function getCommand();
/**
* Method to get action
*
* @return string|null
*/
public function getAction();
/**
* Method to get rule
*
* @return string|null
*/
public function getRule();
/**
* Method to get params to controller
*
* @return array
*/
public function getParams() :array;
/**
* Method to get status code
*
* @return int
*/
public function getStatusCode() :int;
/**
* Method to get status message
*
* @return string|null
*/
public function getStatusMessage();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.