PHP code example of gemvc / library
1. Go to this page and download the library: Download gemvc/library 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/ */
gemvc / library example snippets
namespace App\Api;
use Gemvc\Core\ApiService;
use Gemvc\Http\Request;
use Gemvc\Http\JsonResponse;
use Gemvc\Core\RedisManager;
class User extends ApiService {
public function __construct(Request $request)
{
parent::__construct($request);
}
public function getUsers():JsonResponse {
if(!$this->request->auth(['admin'])) {
return $this->request->returnResponse();
}
$redis = new RedisManager::getInstance();
$redis_key = md5($this->request->requestedUrl);
$response = $redis->getJsonResponse($redis_key);
if(!$response)
{
$response = (new UserController($this->request))->list();
//cach for 10 minutes 600 seconds
$redis->setJsonResponse($redis_key,$response,time()+600);
return $response;
}
return $response;
}
}