1. Go to this page and download the library: Download drewlabs/http-query 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/ */
drewlabs / http-query example snippets
use Drewlabs\Query\Http\Query;
// Instruct the query object to use `http://127.0.0.1:8080` as base domain
$b = Query::new('http://127.0.0.1:8080')
// Select the api path (path to the resource being queried)
->from('api/v1/examples')
// Add a Bearer Authorization header to the request
->withAuthorization(BEARER_TOKEN);
use Drewlabs\Query\Http\Query;
$b = Query::new('http://127.0.0.1:8080')
->from('api/v1/examples')
->withAuthorization(BEARER_TOKEN);
$b->date('created_at', '>', '2023-12-01')
->date('created_at', '<', '2025-02-01')
->exists('comments', fn($b) => $b->in('tags', [1, 4]));
// Executing the query
$result = $b->limit($limit)->execute(); // Calling execute runs the query against the HTTP api and return an instance of \Drewlabs\Query\Http\QueryResult object
print_r($result->getBody()); // returns the actual body of the query
print_r($result->first()); // return the first element of the list of items returned by the query
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.