Example #1
0
<?php

use myMvc\System\Router;
Router::route('get', '/test', function () {
    echo "Subrouter 'Test' works!";
});
Example #2
0
	# When implemented in all Controller methods, this 
	# call should be executed last, at the bottom of this page.
	View::display('App/Views/app.layout.php', []);
});*/
/*
	User routes
*/
# Note that routes without variables should be at the top
# This route uses a closure function (callback) to execute some code
Router::route('get', '/users', 'UserController::index', 'userIndex');
Router::route('get', '/users/create', 'UserController::create', 'userCreate');
Router::route('post', '/users/create', 'UserController::insert', 'userInsert');
# Note that routes with variables should be at the bottom
Router::route('post', '/users/:id', 'UserController::update', 'userUpdate');
Router::route('get', '/users/:id', 'UserController::show', 'userShow');
Router::route('get', '/users/:id/edit', 'UserController::edit', 'userEdit');
# Another example using the View class.
# This time showByView() adds views to multiple sections
/*Router::route('get', '/users/:id', function ($id){
	
	# Initialize a UserController, we'll use the 
	# fully qualified name for this test
	$UserController = new myMvc\App\Controllers\UserController();
	
	# This method adds two views to the 'firstcolumn' and 'secondcolumn' sections 
	# main layout view, App/Views/app.layout.php
	$UserController->showByView($id);

	# For now the View class is only used in this instance
	# When implemented in all Controller methods, this 
	# call should be executed last, at the bottom of this page.