1. Go to this page and download the library: Download symlex/symlex-core 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/ */
symlex / symlex-core example snippets
namespace Symlex\Kernel;
class WebApp extends App
{
protected $urlPrefix = '';
public function __construct($appPath, $debug = false)
{
parent::__construct('web', $appPath, $debug);
}
public function init()
{
if ($this->debug) {
ini_set('display_errors', 1);
}
}
public function getUrlPrefix($urlPrefixPostfix = ''): string
{
return $this->urlPrefix . $urlPrefixPostfix;
}
public function setUrlPrefix(string $urlPrefix)
{
$this->urlPrefix = $urlPrefix;
}
protected function setUp()
{
$container = $this->getContainer();
// The error router catches errors and displays them as error pages
$container->get('router.error')->route();
// Routing for REST API calls
$container->get('router.rest')->route($this->getUrlPrefix('/api'), 'controller.rest.');
// All other requests are routed to matching controller actions
$container->get('router.twig')->route($this->getUrlPrefix(), 'controller.web.');
}
}
use Symlex\Kernel\App;
class WebApp extends App
{
public function __construct($appPath, $debug = false)
{
parent::__construct('web', $appPath, $debug);
}
public function boot () {
parent::boot();
$container = $this->getContainer();
/*
* In app/config/web.yml:
*
* services:
* http.interceptor:
* class: Symlex\Router\HttpInterceptor
*/
$interceptor = $container->get('http.interceptor');
$interceptor->digestAuth('Realm', array('foouser' => 'somepassword'));
$container->get('router.error')->route();
$container->get('router.rest')->route('/api', 'controller.rest.');
$container->get('router.twig')->route('', 'controller.web.');
}
}
$app = new WebApps('web', __DIR__ . '/../app', false);
$app->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.