PHP code example of dinhthibc / feazy

1. Go to this page and download the library: Download dinhthibc/feazy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dinhthibc / feazy example snippets



define('ROOT_PATH', __DIR__);
$loader = 'REQUEST_URI']);
$router->get('/', function() {
	echo 'Welcome to Feazy';
});



namespace Application\Controller;

use Feazy\Controller\Controller;

class UserController extends Controller
{
	public function index() {
		echo 'This is users page';
	}

	public function get($id) {
		echo "Get user details with id = $id";
	}
}


define('ROOT_PATH', __DIR__);

$loader = uter = new \Feazy\Common\Router($_SERVER['REQUEST_URI']);
$router->get('/', function() {
	echo 'Welcome to Feazy';
});

$router->group('/users', function(\Feazy\Common\Router $router) {
	$router->get('/', 'UserController@index');
	$router->get('/(\d+)', 'UserController@get');
});


$router = new \Feazy\Common\Router($_SERVER['REQUEST_URI']);

$router = new \Feazy\Common\Router($_SERVER['REQUEST_URI']);
$router->basicRoute();

$router = new \Feazy\Common\Router($_SERVER['REQUEST_URI']);
$router->group('/users', function(\Feazy\Common\Router $router) {
	$router->get('/', 'UserController@index');
	$router->get('/(\d+)', 'UserController@get'); //using regex
});

$router->group('/api', function(\Feazy\Common\Router $router) {
	$router->setPrefix('\\Application\\API\\'); //set namespace for controller
	$router->get('/users', 'UserController@index');
});


define('ROOT_PATH', __DIR__);

$loader = uter = new \Feazy\Common\Router($_SERVER['REQUEST_URI']);
\Feazy\Common\DIManager::add('view', new \Feazy\Common\View('template'));

$router->get('/', 'IndexController@index');
 

namespace Application\Controller;
use Feazy\Controller\Controller;
class IndexController extends Controller
{
	public function index() {
		$this->view->setTitle('Homepage');
		$this->view->render('index/index', [
			'myVariable' => 'This is a variable value'
		]);
	}
}

<html>
<head>
	<!--- css/meta -->
	<title> echo $this->title; 

myVariable =>  echo $myVariable; 

<div>
	 $this->addSection('sections/component1'); 

myVariable =>  echo $myVariable; 

class IndexController extends Controller
{
	public function index() {
		$this->view->setTitle('Homepage');
		$this->view->render('index/index', [
			'myVariable' => 'This is a variable value'
		]);
	}
}

 echo $myVariable;