1. Go to this page and download the library: Download lucinda/mvc 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/ */
lucinda / mvc example snippets
$handler = new FrontController("configuration.xml", new MyCustomAttributes("application/event_listeners");
$handler->run();
$handler = new FrontController("stdout.xml", new FrameworkAttributes("application/listeners");
$handler->addEventListener(EventType::APPLICATION, Lucinda\Project\EventListeners\Logging::class);
$handler->addEventListener(EventType::REQUEST, Lucinda\Project\EventListeners\Security::class);
$handler->run();
$controller = new Lucinda\STDOUT\FrontController("configuration.xml", new Attributes("application/events"));
// TODO: add event listeners here
$controller->run();
class UserNameValidator implements Lucinda\STDOUT\EventListeners\Validators\ParameterValidator
{
public function validate($value)
{
$result = DB("SELECT id FROM users WHERE name=:name", [":name"=>$value])->toValue();
return ($result?$result:null);
}
}
class StartBenchmark extends Lucinda\STDOUT\EventListeners\Start
{
public function run(): void
{
// you will first need to extend Application and add: setStartTime, getStartTime
$this->attributes->setStartTime(microtime(true));
}
}
class EndBenchmark extends Lucinda\STDOUT\EventListeners\End
{
public function run(): void
{
$benchmark = new Benchmark();
$benchmark->save($this->attributes->getStartTime(), microtime(true));
}
}