PHP code example of siganushka / api-factory

1. Go to this page and download the library: Download siganushka/api-factory 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/ */

    

siganushka / api-factory example snippets


// Configure the options reOptions(OptionsResolver $resolver): void;

// Configure the request with resolved options
AbstractRequest::configureRequest(RequestOptions $request, array $options): void;

// Parse the response data (ParseResponseException when there is an error)
AbstractRequest::parseResponse(ResponseInterface $response): mixed;

namespace App\Request;

use Siganushka\ApiFactory\AbstractRequest;
use Siganushka\ApiFactory\RequestOptions;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\HttpClient\ResponseInterface;

/**
 * @extends AbstractRequest<array>
 */
class GithubUsers extends AbstractRequest
{
    protected function configureOptions(OptionsResolver $resolver): void
    {
        $resolve
            ->define('username')
            ->sers();

$result = $request->send();
// throws MissingOptionsException: The l": "https://api.github.com/users/siganushka/gists{/gist_id}",
//  ...
// }