1. Go to this page and download the library: Download lim6112j/apicenter 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/ */
lim6112j / apicenter example snippets
t
public function execute($data=[]):array
{
($data['member_uid'] && $data['member_uid']>0)
?: header('Location:/login');
return $data;
}
t
...
return [];
// http://localhost/newpage로 요청이오면 DefaultController에 있는 newpage 함수를 실행하라.
$app->router->get('/newpage', [DefaultController::class, 'newpage']);
$app->router->get('/newpage.php', [DefaultController::class, 'newpage']);
public function newpage(): string
{
$params = ['name' => 'the cheat'];
return $this->render('newpage', $params); // views 폴더에서 newpage.php를 찾아 렌더링.
}
<h1>Hello echo $name
namespace app\middlewares;
use app\core\BaseMiddleware;
class NewMiddleware extends BaseMiddleware
{
//BaseMiddleware에서 상속된 필수 구현 함수.
public function execute()
{
if(something wrong) {
exit;
}
}
}
class AuthMiddleware extends BaseMiddleware
{
protected static $_instance = null;
public static function getInstance()
{
if (static::$_instance === null)
{
static::$_instance = new static();
}
return static::$_instance;
}
public function execute():array
{
$login_array['now_year'] = date("Y");
$login_array['now_month'] = date("m");
return $login_array;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.