@@ -39,11 +39,18 @@ public static function view($view = '', $data = [])
3939 {
4040 // mengarah pada folder apps/views/ namaviews.php
4141 try {
42- if (!file_exists (' apps/views/ ' . $ view . '.php ' )) {
42+ if (!file_exists (_ROOT_VIEW . $ view . '.php ' )) {
4343 throw new Exception ("View " . $ view ." Not Found. Check Controllernya Bro " );
4444 }
4545
46- require_once 'apps/views/ ' . $ view . '.php ' ;
46+ # comment this jika tidak ingin menggunakan twig engine
47+ // $loader = new \Twig\Loader\FilesystemLoader(_ROOT_VIEW);
48+ // $twig = new \Twig\Environment($loader, ['debug' => true]);
49+
50+ // echo $twig->render($view . '.php' , $data);
51+
52+ # uncomment this jika tidak ingin menggunakan twig engine
53+ require_once _ROOT_VIEW . $ view . '.php ' ; //update template engine menggunakan twig
4754 exit ;
4855 } catch (Exception $ exception ) {
4956 $ my_error = new Error_Handling ;
@@ -62,11 +69,11 @@ public static function model($model = '')
6269 // mengarah pada folder apps/models/ namamodels.php
6370
6471 try {
65- if (!file_exists (' apps/models/ ' . $ model . '.php ' )) {
72+ if (!file_exists (_ROOT_MODEL . $ model . '.php ' )) {
6673 throw new Exception ("Models " . $ model ." Not Found. Check Controllernya Bro di bagian load modelnya " );
6774 }
6875
69- require_once ' apps/models/ ' . $ model . '.php ' ;
76+ require_once _ROOT_MODEL . $ model . '.php ' ;
7077 return new $ model ;
7178 exit ;
7279 } catch (Exception $ exception ) {
@@ -86,10 +93,12 @@ public static function error_view($view = '', $data = [])
8693 // mengarah pada folder apps/error/pages/ namaviews.php
8794 try {
8895
89- if (!file_exists (' apps/error/pages/ ' . $ view . '.php ' )){
96+ if (!file_exists (_ROOT_ERROR_VIEW . $ view . '.php ' )){
9097 throw new Exception ("views " . $ view ." Not Found. Check Controllernya Bro di bagian load view-nya " );
9198 }
92- require_once 'apps/error/pages/ ' . $ view . '.php ' ;
99+
100+ require_once _ROOT_ERROR_VIEW . $ view . '.php ' ;
101+
93102
94103 } catch (\Throwable $ exception ) {
95104 $ my_error = new Error_Handling ;
0 commit comments