1. Go to this page and download the library: Download globalxtreme/parser 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 / parser example snippets
use GlobalXtreme\Parser\BaseParser;
class CustomParser extends BaseParser
{
use HasParser;
public function tests($collections)
{
if (!$collections || count($collections) == 0) {
return null;
}
$data = [];
foreach ($collections as $collection) {
$data[] = $collection->toArray();
}
return $data;
}
}
use App\Packages\Parser\Custom\CustomParser;
use GlobalXtreme\Parser\Trait\HasParser;
class Custom extends Model
{
use HasParser;
public $parserClass = CustomParser::class;
}
use App\Http\Controllers\Controller;
use App\Models\Custom;
use App\Packages\Parser\Custom\CustomParser;
use GlobalXtreme\Parser\Parser;
class CustomController extends Controller
{
public function testing()
{
// Get more than one data
$customs = Custom::get();
// Display data using CustomParser and your custom function
$results = CustomParser::get($customs);
$results = CustomParser::tests($customs);
// Display data using parser class from package
// with default function or custom function from CustomParser
$results = Parser::get($customs);
$results = Parser::tests($customs);
// Get one data
$custom = Custom::first();
// Display data using custom parser
$result = CustomParser::first($custom);
// Display data using parser class from package
$result = Parser::first($custom);
}
}