PHP code example of thombas / revised-service-pattern
1. Go to this page and download the library: Download thombas/revised-service-pattern 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/ */
thombas / revised-service-pattern example snippets
use Thombas\RevisedServicePattern\Services\RestApiService;
class MyApiService extends RestApiService
{
protected function setup(): static
{
return $this->baseUrl('https://api.example.com')->asJson();
}
}
class FetchUserEndpoint extends MyApiService
{
protected function setup(): static
{
return parent::setup()
->setUrl('user')
->setMethod(ServiceMethodEnum::Get)
->setParamaters(['id' => 123]);
}
}
public function __construct(protected string $userId)
{
parent::__construct();
}