1. Go to this page and download the library: Download allenlinatoc/php-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/ */
allenlinatoc / php-container example snippets
return function ($container) {
return new \Slim\Views\Twig(
\Highdesk\Utils\FileSystem::root("/public/views"),
[
"cache" => \Highdesk\Utils\FileSystem::root("/.twigcache")
]
);
};
// As array
$container["view"] = (P-DI's way)
$container->set("view", (od kicks in)
$container->view = (
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
// As Array
$this["view"]->render($response, 'index.phtml', compact('name'));
// Through "get" method (like PHP-DI's way)
$this->get("view")->render($response, 'index.phtml', compact('name'));
// Or as property (via __get() magic method)
$this->view->render($response, 'index.phtml', compact('name'));
return $response;
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.