Extending CEO
Client Namespace
You can extend the core of CEO Front End by creating a new module in the client repository. In the library/
folder, create a new file called Module.php
that looks like the following, here Abc
is the client's short code:
<?php
namespace Ceo\Modules\Abc;
use Phalcon\DiInterface;
use Phalcon\Loader;
use Phalcon\Mvc\ModuleDefinitionInterface;
class Module implements ModuleDefinitionInterface
{
/**
* Registers an autoloader related to the module
*
* @param DiInterface $di
*/
public function registerAutoloaders(DiInterface $di = null)
{
$loader = new Loader();
$loader->registerNamespaces([
'Abc' => __DIR__ . '/src'
]);
$loader->register();
}
/**
* Registers services related to the module
*
* @param DiInterface $di
*/
public function registerServices(DiInterface $di)
{
// register any services
}
}
You can then load any necessary libraries or services. You could even override existing services as necessary.
Custom code would then go into the library/src
folder and all have the root namespace Abc
, or whatever the client short code is.
Custom Commands
Custom commands can be written and executed as necessary. First, build your command, which is a file that returns a function. The function receives 3 arguments. Input parser, output parser and the dependency injector:
<?php
return function($input, $output, $di)
{
$output->writeln('Hi there');
};
You can then run your command thusly:
php run client:run --client xxx path/to/command.php