PHP code example of symplify / symbiotic-controller
1. Go to this page and download the library: Download symplify/symbiotic-controller 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/ */
symplify / symbiotic-controller example snippets
namespace App\Presenter;
use Symplify\SymbioticController\Contract\Template\TemplateRendererInterface;
final class StandalonePresenter
{
/**
* @var TemplateRendererInterface
*/
private $templateRenderer;
public function __construct(TemplateRendererInterface $templateRenderer)
{
$this->templateRenderer = $templateRenderer;
}
public function __invoke(): string
{
return $this->templateRenderer->renderFileWithParameters(
__DIR__ . '/templates/Contact.latte'
);
}
}
namespace App\Presenters;
use Nette\Application\Responses\TextResponse;
final class ContactPresenter
{
public function __invoke(): TextResponse
{
return new TextResponse('Hi!');
}
}
namespace App\Presenters;
use Nette\Application\Responses\JsonResponse;
final class ContactPresenter
{
public function __invoke(): TextResponse
{
return new JsonResponse('Hi!');
}
}
# app/Router/RouterFactory.php
namespace App\Router;
final class RouterFactory
{
public function create(): RouteList
{
$routes = new RouteList;
$routes[] = new PresenterRoute('/contact', ContactPresenter::class);
$routes[] = new Route('<presenter>/<action>', 'Homepage:default');
return $routes;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.