PHP code example of triplepoint / groundhog-router
1. Go to this page and download the library: Download triplepoint/groundhog-router 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/ */
triplepoint / groundhog-router example snippets
php
// ### HttpRequestWrapper.php ###
namespace MyProject;
use \Symfony\Component\HttpFoundation\Request;
use \Groundhog\Router\RequestInterface;
class HttpRequestWrapper implements Router\RequestInterface
{
protected $request;
public function __construct( Request $request )
{
$this->request = $request;
}
public function getPathInfo()
{
return $this->request->getPathInfo();
}
public function getUri()
{
return $this->request->getUri();
}
public function getHost()
{
return $this->request->getHost();
}
public function getMethod()
{
return $this->request->getMethod();
}
}
php
// ### ServiceContainer.php ###
namespace MyProject;
use \Groundhog\Router\RouteHandlerServiceContainerInterface;
use \Pimple
class ServiceContainer extends Pimple implements RouteHandlerServiceContainerInterface
{
public function __construct()
{
parent::__construct();
$this['some_dependency'] = function ($c) {
// This dependency is destined to end up in the Route Handler's $some_dependency property
return new SimpleXmlElement();
};
}
}