Core classes for Xervice services
composer require xervice/core
You need no configuration to use this package. But you can define the namespaces.
Main Projectnamespace
use Xervice\Core\CoreConfig;
$config[CoreConfig::CORE_NAMESPACES] = [
'Xervice'
];
$config[CoreConfig::PROJECT_NAMESPACES] = [
'App'
];
You can create your own Xervice packages. For that you have to use a project namespace and create a module directory. In that directory you can use some predefined patterns like Facade, Factory, DependencyProvider, Config and Client.
Structure .
- src
- MyNamespace
- MyModule
- Business
- MyModuleFacade.php
- MyModuleBusinessFactory.php
- Communication
- MyModuleCommunicationFactory.php
- MyModuleDependencyProvider.php (For the communication layer)
- Persistence
- MyModuleReader.php
- MyModuleWriter.php
- MyModuleConfig.php
- MyModuleDependencyProvider.php (For the business layer)
- Business
- MyModule
- MyNamespace
If you don't need one of these classes, you can remove them.
To use your Module you can use the core locator in your application:
<?php
$locator = \Xervice\Core\Locator\Locator::getInstance();
$locator->myModule()->facade()->publicMethod();
There are two dynamic locator traits:
- DynamicBusinessLocator
- DynamicCommunicationLocator
Communication -> Business -> Persistence
- In the communication layer you can access the communication factory
- In the communication layer you can access the facade from your BusinessLayer.
- In the BusinessLayer facade you can access the business factory
- In the business factory you can access the reader and writer from the persistence layer
Business and communication have their own dependency container. You can access them from the factory.
To extend a module, you can create a directory with the same name in an upper level namespace. The order of the namespaces is:
- Core-Namespaces in defined order (Default: Xervice)
- Project namespace in defined order (Default: App)
If you have an module in the Xervice namespace, you can overwrite the classes in your Projectnamespaces. And that logic you can also extend in lower projectnamespaces.
To generate a module you can use the xervicecli package.