1. Go to this page and download the library: Download lexide/syringe 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/ */
lexide / syringe example snippets
use Lexide\Syringe\Syringe;
$appDir = __DIR__;
$configFiles = [
"config/syringe.yml" // add paths to your configuration files here
];
Syringe::init($appDir, $configFiles);
$container = Syringe::createContainer();
$basePath = "/var/www/app";
$resolver = new Lexide\Syringe\ReferenceResolver();
$builder = new Lexide\Syringe\ContainerBuilder($resolver, [$basePath]);
$builder->addConfigfile("config/syringe.yml");
...
$basePaths = [
"my-dir/config", // both these paths contain a file called "foo.yml"
"my-dir/app"
];
$resolver = new Lexide\Syringe\ReferenceResolver();
$builder = new Lexide\Syringe\ContainerBuilder($resolver, $basePaths);
$builder->addConfigfile("foo.yml"); // will load my-dir/config/foo.yml, as that is the first base path in the list
use Lexide\Syringe\Loader\LoaderInterface;
class XmlLoader implements LoaderInterface
{
public function getName()
{
return "XML Loader";
}
public function supports($file)
{
return pathinfo($file, PATHINFO_EXTENSION) == "xml";
}
public function loadFile($file)
{
// load and decode the file, returning the configuration array
}
}
$container = new Pimple\Container();
$builder->populateContainer($contianer);