PHP code example of usamamuneerchaudhary / laraclient
1. Go to this page and download the library: Download usamamuneerchaudhary/laraclient 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/ */
usamamuneerchaudhary / laraclient example snippets
use Usamamuneerchaudhary\LaraClient\Auth\AuthFactory;
AuthFactory::extend('hmac', fn (array $config) => new HmacAuth($config['secret']));
LaraClient::connection('github')->get('users/{username}/repos', [
'username' => 'usamamuneerchaudhary', // fills the path placeholder
'sort' => 'updated', // left over, so it becomes a query parameter
]);
class GithubClient
{
/**
* Fetch a single part of a widget
*
* @param int $widgetId Numeric widget id
*/
public function getWidgetPart(int $widgetId, string $partId, array $query = []): Response
{
return $this->request()->get('widgets/{widgetId}/parts/{partId}', [
'widgetId' => $widgetId, 'partId' => $partId,
] + $query);
}
}
bash
LARACLIENT_RECORDER=record php artisan test --filter=GithubTest # captures fixtures
LARACLIENT_RECORDER=replay php artisan test # hermetic, no network
bash
php artisan laraclient:check # ping every connection; fails the build on a bad credential
php artisan laraclient:prune # trim the logs table (schedule this daily)
php artisan laraclient:make github --spec=openapi.json
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.