1. Go to this page and download the library: Download minphp/container 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/ */
minphp / container example snippets
use Minphp\Container\Container;
$container = new Container();
// Add/Update
$container->set('queue', function($c) {
return new \SplQueue();
});
// Verify
$queue_exists = $container->has('queue');
// Fetch
$queue = $container->get('queue');
// Remove
$container->remove('queue');
use Minphp\Container\Container;
$container = new Container();
$container['queue'] = function($c) {
return new \SplQueue();
};
$queue = $container['queue'];
interface ContainerInterface
{
// inherited from Interop\Container\ContainerInterface
public function get($id);
// inherited from Interop\Container\ContainerInterface
public function has($id);
public function set($id, $value);
public function remove($id);
}
interface ContainerAwareInterface
{
public function setContainer(Minphp\Container\ContainerInterface $container = null);
public function getContainer();
}
namespace myApp\Controller;
use Minphp\Container\ContainerAwareInterface;
use Minphp\Container\ContainerInterface;
class MyController implements ContainerAwareInterface
{
private $container = null;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function getContainer()
{
return $this->container;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.