1. Go to this page and download the library: Download aliirfaan/citronel-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/ */
aliirfaan / citronel-core example snippets
namespace App\Services\Api\v1\Helper;
use aliirfaan\CitronelCore\Services\CitronelHelperService;
use aliirfaan\CitronelCore\Traits\CitronelCorrelationTokenTrait;
// create your helper service that extends CitronelHelperService
class HelperService extends CitronelHelperService
{
// use traits
use CitronelCorrelationTokenTrait;
}
namespace App\Http\Controllers\Api\v1;
use aliirfaan\CitronelCore\Http\Controllers\CitronelController;
use aliirfaan\LaravelSimpleApi\Http\Resources\ApiResponseCollection;
use aliirfaan\CitronelCore\Traits\CitronelApiControllerTrait;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Services\Api\v1\Helper\HelperService;
// create your own controller and extend CitronelController
class CustomCitronelController extends CitronelController
{
use CitronelApiControllerTrait;
public function __construct()
{
parent::__construct();
$this->helperService = new HelperService();
}
public function index(Request $request)
{
$this->data['result'] = null;
$this->data['status_code'] = Response::HTTP_OK;
$this->resultResponse = new ApiResponseCollection($this->data);
// cache response
$cacheConfigKey = 'cache_example_process';
$this->helperService->cacheResponse($cacheConfigKey, $resultResponse);
// return response
return $this->sendApiResponse($this->resultResponse, $this->resultResponse->collection['status_code']);
}
}