PHP Classes

File: app.php

Recommend this page to a friend!
  Classes of Kabir Hossain   Sage   app.php   Download  
File: app.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Sage
Demo application of Web development framework
Author: By
Last change:
Date: 1 year ago
Size: 1,123 bytes
 

Contents

Class file image Download
<?php
    $router
= new AltoRouter();
   
$router->setBasePath($base_path);
    @require_once
'routes/web.php';
   
   
$match = $router->match();
    if(
is_array($match)) { // && is_callable( $match['target'] ) ) {
        // Load vendor after route confirmation
       
@require App . 'config/config.php';
        @require_once
App . 'config/database.php';

       
// Get controller and action from router url
       
list( $controller, $action ) = explode( '@', $match['target'] );
       
//App\Controllers\DemoController;
       
$controller = "App\Controllers".'\\'.$controller;
       
$controller = new $controller();
        if(
method_exists($controller,$action)) {
            if(!empty(
$match['params'])){
               
call_user_func_array([$controller,$action],$match['params']);
            }
            else {
               
$controller->{$action}();
            }
            exit();
        }
    }

   
// no route was matched or method missing
   
$errors = [
   
//'title' => 'URL not found.',
    //'message' => 'Please go back and try again.'
   
];
    return
view('errors/404',$errors,false);