PHP code example of lin-cms-tp / param-core
1. Go to this page and download the library: Download lin-cms-tp/param-core 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/ */
lin-cms-tp / param-core example snippets
return [
// 默认中间件命名空间
'default_namespace' => 'app\\http\\middleware\\',
'linRouteParam' => LinCmsTp\Param::Class
];
/**
* Class Book
* @route('v1/book')
* @middleware('linRouteParam')
* @package app\api\controller\v1
*/
class Book
{}
/**
* 账户登陆
* @route('cms/user/login','post')
* @param Request $request
* @validate('LoginForm')
* @return array
* @throws \think\Exception
*/
public function login(Request $request)
{
(new LoginForm())->goCheck();
$params = $request->post();
$user = LinUser::verify($params['nickname'], $params['password']);
$result = Token::getToken($user);
logger('登陆领取了令牌', $user['id'], $user['nickname']);
return $result;
}
/**
* 账户登陆
* @route('cms/user/login','post')
* @param Request $request
* @validate('\app\api\validate\user\LoginForm')
* @return array
* @throws \think\Exception
*/
public function login(Request $request)
{
(new LoginForm())->goCheck();
$params = $request->post();
$user = LinUser::verify($params['nickname'], $params['password']);
$result = Token::getToken($user);
logger('登陆领取了令牌', $user['id'], $user['nickname']);
return $result;
}
/**
* 查询指定bid的图书
* @route('v1/book/:bid','get')
* @param Request $bid
* @param('bid','bid的图书','