Commit 6ef06f2f authored by Heiko Mettelsiefen's avatar Heiko Mettelsiefen 💬

new rease, better routing

parent e87fa8f9
# 1.0.8
## notes
* optimize routing
## added
* catch easy get and post parameters
## fixed
-
## removed
- app route
# 1.0.7
## notes
* optimize codeformatting
......
......@@ -78,8 +78,11 @@ class indexController {
$this->view = "Hi, i am a view object";
$this->user = "I am a user!";
# or init a model
$this->dir = new HM\Dir('/path_to/MyNewDirectory');
$this->dir = new HM\Dir('/path_to/MyNewDirectory');
# get params
# $page->_get
# $page->_post
}
......
......@@ -3,16 +3,11 @@ require __DIR__ . '/globals/header.php';
require __DIR__ . '/globals/settings.php';
require __DIR__ . '/vendor/autoload.php';
if ($base_url = dirname($_SERVER["SCRIPT_NAME"]) !== '/') {
$app_route = str_replace($base_url, '', $_SERVER["REQUEST_URI"]);
} else {
$app_route = $_SERVER["REQUEST_URI"];
}
$page = new simple\MVC($app_route);
// create the page object by uri
$page = new simple\MVC($_SERVER["REQUEST_URI"]);
# show info about the $page object
#var_dump($page);
#var_dump($page);die();
// routing to 404, if the page not found
if ($page->view->path === false) : header('Location: '.'/notFound'); endif;
......
......@@ -11,6 +11,7 @@ use HM;
*
*/
public $page;
public $params;
public $controller;
public $method;
......@@ -55,13 +56,20 @@ use HM;
* -
*
*/
private function page($page)
private function page($url)
{
# define page from the uri
$page = ltrim(rtrim($page, '/'), '/');
$this->page = ($page === '') ? 'index' : $page;
$url = ltrim(rtrim($url, '/'), '/');
# define page from the uri
$page = parse_url($url);
$this->_post = $_POST;
$this->_get = (isset($page['query'])) ? $page['query'] : null;
$this->page = ($page['path'] === '') ? 'index' : $page['path'];
}
/**
* Controller
......
......@@ -5,7 +5,7 @@
Getting started, open <strong><i>/controller/<?= $page->controller->file; ?></i></strong>
and modifiy function <strong><i><?= $page->controller->action; ?></i></strong>!
</p>
<p>Catch easy data from controller with <i>$view</i></p>
<p>Catch easy data from controller with <i>$view</i></p>
<P><pre><? var_dump($view) ?></pre></P>
<p>powered by <a href="https://gitlab.com/mascoda/simple-mvc">simple-mvc</a></p>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment