1. Go to this page and download the library: Download webiny/service-manager 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/ */
webiny / service-manager example snippets
$config = [
'Class' => '\My\Service\Class'
];
ServiceManager::getInstance()->registerService('MyService', new ConfigObject($config));
// Now get your service
$myService = ServiceManager::getInstance()->getService('MyService');
$config = [
'MyLogger' => [
'Class' => '\My\Service\Class'
],
'MyMailer' => [
'Class' => '\My\Mailer\Class'
]
];
ServiceManager::getInstance()->registerServices('MyServiceGroup', new ConfigObject($config));
// Now get your specific service
$myMailer = ServiceManager::getInstance()->getService('MyServiceGroup.MyMailer');
class YourClass{
use ServiceManagerTrait;
public function yourMethod(){
$services = $this->servicesByTag('logger');
}
}
class YourClass{
use ServiceManagerTrait;
public function yourMethod(){
$services = $this->servicesByTag('cms_plugin', '\Your\Expected\Class\Or\Interface');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.