1. Go to this page and download the library: Download picamator/object-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/ */
picamator / object-manager example snippets
class UserRepository
{
private $connection;
public function __construct()
{
$this->connection = new Connection();
}
}
class UserRepository
{
private $connection;
public function __construct()
{
$this->connection = ObjectManagerSingleton::getInstance()->create('Connection');
}
}
class ConnectionFactory
{
public function create()
{
return new Connection();
}
}
class ConnectionFactory
{
private $objectManager;
private $className;
public function __construct(ObjectManager $objectManager, $className = 'Connection')
{
$this->objectManager = $objectManager;
$this->className = $className;
}
public function create()
{
return $this->objectManager->create($this->className);
}
}
declare(strict_types=1);
class ConnectionFactory
{
private $objectManager;
private $className;
public function __construct(ObjectManager $objectManager, string $className = 'Connection')
{
$this->objectManager = $objectManager;
$this->className = $className;
}
public function create() : ConnectionInterface
{
return $this->objectManager->create($this->className);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.