PHP code example of lfphp / plite

1. Go to this page and download the library: Download lfphp/plite 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/ */

    

lfphp / plite example snippets




//The content of the configuration file site.inc.php is:

return [
	'name'=>'Site 1',
'admin' => [
'user'=>'jack',
'email'=>'[email protected]'
]
];

//Get the configuration method:
//1. Get the site name:
$site_name = get_config('site/name');

//2. Get the site administrator's email address
$admin_email = get_config('site/admin/email');

return [
//Mode ① URI matching => class name + '@' + method name
'' => IndexController::class.'@index',
'user/create' => UserController::class.'@create',
        
//Mode ② contains wildcard URI string => class name + '@' + method name, or wildcard
'product/*' => UserController::class.'@*',
]


//?r=user/create
echo url('user/create'); //Generate a URL route to create a user

//<input name="r" value="user/update"/>
//<input name="id" value="1"/>
echo url_input('user/update', ['id'=>1]); //Generate an HTML input string for updating user 1 information

//Recommend Controller model

/**
* Controller is a common parent class defined by the public, which is convenient for implementing unified logic processing in the Controller::__construct() method
*/
class Order extends Controller {
use AuthorizedTrait; //It is recommended to create traits to implement capabilities such as authentication
    
/**
* @param array $request //The framework routing mechanism uniformly passes the $_REQUEST variable to the action method
*/
public function index($request){
self::noVisited();
var_dump($request['hello']);
}
    
/**
* Static methods will not be accessed by routing
*/
public static function noVisited(){
        
}
}