corrigindo rotas

This commit is contained in:
Reginaldo
2023-06-13 18:08:42 -03:00
parent 20fc580fe2
commit 00d21cc8c5
11 changed files with 182 additions and 22 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace app\controllers;
use League\Plates\Engine;
class Controller{
public static function view(string $view, array $data = []){
$viewsPath = dirname(__FILE__,2)."/views";
if(!file_exists($viewsPath . DIRECTORY_SEPARATOR . $view.".php")){
throw new \Exception("A view {$view} não existe");
}
$templates = new Engine($viewsPath);
echo $templates-> render($view,$data);
}
}

View File

@@ -2,5 +2,7 @@
namespace app\controllers;
class HomeController{
public function index(){
return Controller::view("home");
}
}

View File

@@ -2,5 +2,11 @@
namespace app\controllers;
class LoginController{
public function index(){
return Controller::view("login");
}
public function store(){
var_dump('store do login');
}
}