for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Test;
use League\Container\ServiceProvider\AbstractServiceProvider;
/**
* Description of ServiceProvider
*
* @author d.lanec
*/
class ServiceProvider extends AbstractServiceProvider {
protected $provides = [
'UserMapper',
'UserGroupMapper',
'CityMapper'
];
public function register() {
global $__AR2, $CONST;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
$db = new \SimpleORM\Adapter\CodeigniterQueryBuilder(get_instance()->db);
$this->getContainer()->add('UserMapper','Test\Domain\User\UserMapper')
->withArgument($this->getContainer())
->withArgument($db)
->withArgument($__AR2['autoresource_db']);
$this->getContainer()->add('UserGroupMapper','Test\Domain\UserGroup\UserGroupMapper')
$this->getContainer()->add('UserAddressMapper','Test\Domain\UserAddress\UserAddressMapper')
$this->getContainer()->add('CityMapper','Test\Domain\City\CityMapper')
}
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state