1. Go to this page and download the library: Download globalxtreme/response 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/ */
globalxtreme / response example snippets
use App\Packages\Response\Constant\Error;
if (!function_exists("errTestingCustom")) {
function errTestingCustom($internalMsg = "")
{
error(Error::DEFAULT, $internalMsg);
}
}
use App\Http\Controllers\Controller;
use App\Models\Custom;
use GlobalXtreme\Parser\Parser;
use GlobalXtreme\Response\Response;
use GlobalXtreme\Response\Status;
class CustomController extends Controller
{
public function testing()
{
// Get more than one data
$customs = Custom::get();
// Display data auto call parser from Response package
$results = success($customs);
// Display data using parser class
$result = success(Parser::get($customs));
// Get one data
$custom = Custom::first();
// Display data auto call parser from Response package
$result = success($custom);
// Display data using parser class
$result = success(Parser::first($custom));
// Get data with pagination
$customs = Custom::paginate(10);
// Display data auto call parser from Response package
$results = success($customs);
// Display data using parser class and manual process pagination
$results = success(Parser::get($customs), pagination: pagination($customs));
// Display response using Response::class
$status = new Status(true);
// You can choose response type json/object
$results = Response::json($status, $customs);
$results = Response::object($status, $customs);
}
}