PHP Classes

File: app/routes.php

Recommend this page to a friend!
  Classes of ikhsan   Slim Starter   app/routes.php   Download  
File: app/routes.php
Role: Application script
Content type: text/plain
Description: routing configuration
Class: Slim Starter
Build MVC Web applications based on Slim framework
Author: By
Last change: Update of app/routes.php
Date: 5 months ago
Size: 1,461 bytes
 

Contents

Class file image Download
<?php

/**
 * Sample group routing with user check in middleware
 */
Route::group(
   
'/admin',
    function(){
        if(!
Sentry::check()){

            if(
Request::isAjax()){
               
Response::headers()->set('Content-Type', 'application/json');
               
Response::setBody(json_encode(
                    array(
                       
'success' => false,
                       
'message' => 'Session expired or unauthorized access.',
                       
'code' => 401
                   
)
                ));
               
App::stop();
            }else{
               
$redirect = Request::getResourceUri();
               
Response::redirect(App::urlFor('login').'?redirect='.base64_encode($redirect));
            }
        }
    },
    function() use (
$app) {
       
/** sample namespaced controller */
       
Route::get('/', 'Admin\AdminController:index')->name('admin');

        foreach (
Module::getModules() as $module) {
           
$module->registerAdminRoute();
        }
    }
);

Route::get('/login', 'Admin\AdminController:login')->name('login');
Route::get('/logout', 'Admin\AdminController:logout')->name('logout');
Route::post('/login', 'Admin\AdminController:doLogin');

/** Route to documentation */
Route::get('/doc(/:page+)', 'DocController:index');


foreach (
Module::getModules() as $module) {
   
$module->registerPublicRoute();
}

/** default routing */
Route::get('/', 'HomeController:welcome');