1. Go to this page and download the library: Download zfcampus/zf-console library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// config/routes.phpreturnarray(
array(
'name' => 'self-update',
'description' => 'When executed via the Phar file, performs a self-update by querying
the package repository. If successful, it will report the new version.',
'short_description' => 'Perform a self-update of the script',
),
array(
'name' => 'build',
'route' => '<package> [--target=]',
'description' => 'Build a package, using <package> as the package filename, and --target
as the application directory to be packaged.',
'short_description' => 'Build a package',
'options_descriptions' => array(
'<package>' => 'Package filename to build',
'--target' => 'Name of the application directory to package; defaults to current working directory',
),
'defaults' => array(
'target' => getcwd(), // default to current working directory
),
'handler' => 'My\Builder',
),
);
$dispatcher = new ZF\Console\Dispatcher;
$dispatcher->map('some-command-name', $callable)
namespaceZF\Console;
useZend\Console\Adapter\AdapterInterfaceasConsoleAdapter;
interfaceDispatcherInterface{
/**
* Map a command name to its handler.
*
* @param string $command
* @param callable|string $command A callable command, or a string service
* or class name to use as a handler.
* @return self Should implement a fluent interface.
*/publicfunctionmap($command, $callable);
/**
* Does the dispatcher have a handler for the given command?
*
* @param string $command
* @return bool
*/publicfunctionhas($command);
/**
* Dispatch a routed command to its handler.
*
* @param Route $route
* @param ConsoleAdapter $console
* @return int The exit status code from the command.
*/publicfunctiondispatch(Route $route, ConsoleAdapter $console);
}
$application = new Application('App', 1.0, $routes, null, $dispatcher);
$serviceManager = new ServiceManager(/* ... */);
// use `zend-servicemanager` as container
$dispatcher = new Dispatcher($serviceManager);
$application = new Application('App', 1.0, $routes, null, $dispatcher);