1. Go to this page and download the library: Download dcousineau/orlex 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/ */
namespace app\Controllers;
use Orlex\Annotation\Route;
use Orlex\Annotation\Before;
use Orlex\Annotation\After;
/**
* @Route(path="/")
*/
class IndexController {
/**
* @Route(path="/", name="root")
* @Before("beforeIndex")
* @After("afterIndex")
*/
public function indexAction() { /* Do Stuff */ }
public function beforeIndex() { /* Do Stuff Before */ }
public function afterIndex() { /* Do Stuff After */ }
/**
* @Route(path="/page/{id}", name="root_page", methods={"GET", "POST"})
*/
public function pageAction($id) { /* Do Stuff With $id */ }
}
namespace app\Controllers;
use Orlex\Annotation\Route;
use Orlex\ContainerAwareTrait;
use Orlex\Controller\TwigTrait;
/**
* @Route(path="/")
*/
class IndexController {
use ContainerAwareTrait;
use TwigTrait;
/**
* @Route(path="/", name="root")
*/
public function indexAction() {
return $this->render('index.html.twig', []);
}
}