1. Go to this page and download the library: Download aheinze/lime 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/ */
$app->get("/", function() {
return "This was a GET request...";
});
$app->post("/", function() {
return "This was a POST request...";
});
$app->bind("/", function() {
return "This was a GET or POST request...";
});
class Pages {
protected $app;
public function __construct($app){
$this->app = $app;
}
/*
accessible via
/pages or /pages/index
*/
public function index() {
return $this->app->render("pages/index.php");
}
/*
accessible via
/pages/contact
*/
public function contact() {
return $this->app->render("pages/contact.php");
}
/*
accessible via
/pages/welcome/foo
*/
public function welcome($name) {
return $this->app->render("pages/welcome.php", array("name"=>$name));
}
}
// bind Class to map routes
$app->bindClass("Pages");
$app["config.mykey"] = array('test' => 123);
$value = $app["config.mykey/test"]; // will return 123
$app->service("db", function(){
// object will be lazy created after accessing $app['db']
$obj = new PDO(...);
return $obj;
});
$app["db"]->query(...);