Installation Add the package via Composer:
composer require milestone/ebis
Publish the configuration (if available):
php artisan vendor:publish --provider="Milestone\eBis\eBisServiceProvider"
Check config/ebis.php for API credentials, endpoints, or default settings.
Basic Usage The package likely wraps eBis API calls. Start with the client initialization:
use Milestone\eBis\Facades\eBis;
$client = eBis::client(['api_key' => 'your_key_here']);
Verify the facade/class structure in src/ or facades/.
First API Call Example: Fetch a report or entity (adjust based on package docs):
$response = $client->get('/reports/123');
$data = $response->json();
Check the src/Client.php or src/HttpClient.php for available methods.
src/: Core logic (client, models, exceptions).config/ebis.php: Default settings (API endpoints, timeouts, etc.).tests/: Example usage and edge cases.README.md: May include quick-start examples (though minimal for this package).Scenario: Fetch and display a customer’s order history.
$client = eBis::client(['api_key' => config('ebis.api_key')]);
$orders = $client->get('/customers/123/orders')->json();
// Process orders (e.g., loop and store in DB)
foreach ($orders['data'] as $order) {
Order::create([
'customer_id' => 123,
'ebis_order_id' => $order['id'],
'amount' => $order['total'],
]);
}
API Client Initialization Reuse the client across requests (avoid re-authenticating):
$client = eBis::client(['api_key' => config('ebis.api_key')]);
Handling Responses Normalize responses with a helper:
$response = $client->get('/entities');
if ($response->successful()) {
return response()->json($response->json());
}
throw new \Exception($response->error());
Pagination If the API supports pagination, implement a loop:
$page = 1;
do {
$response = $client->get("/entities?page=$page");
$data = $response->json();
// Process $data['data']
$page = $data['next_page'] ?? null;
} while ($page);
Webhook Listeners If eBis supports webhooks, create a listener:
// In EventServiceProvider
$this->listenForWebhooks();
$this->app->singleton('ebis.client', function () {
return eBis::client(['api_key' => config('ebis.api_key')]);
});
SyncEbisData::dispatch($client, $entityId)->onQueue('ebis');
$data = Cache::remember("ebis_report_{$reportId}", now()->addHours(1), function () use ($client, $reportId) {
return $client->get("/reports/$reportId")->json();
});
event(new EbisDataFetched($data));
$mock = Mockery::mock('overload:Milestone\eBis\Client');
$mock->shouldReceive('get')->andReturn((object) ['json' => fn() => []]);
$response = $this->get('/api/ebis-data');
$response->assertJsonStructure(['data' => ['id', 'name']]);
API Key Management
.env).config/ebis.php and reference via config('ebis.api_key').Rate Limiting
use Symfony\Component\HttpClient\RetryableHttpClient;
$client = new RetryableHttpClient(
eBis::client()->getHttpClient(),
[
'max_retries' => 3,
'delay' => 1000,
]
);
Deprecated Methods
class CustomEbisClient extends \Milestone\eBis\Client {
public function get($endpoint) {
// Custom logic
}
}
Error Handling
try {
$response = $client->get('/invalid-endpoint');
} catch (\Milestone\eBis\Exceptions\ApiException $e) {
Log::error($e->getMessage());
}
$client->getHttpClient()->getProgressiveLogger()->tap(
fn($log) => Log::debug('eBis API Call', ['log' => $log])
);
config/ebis.php:
'debug' => env('EBI_DEBUG', false),
Accept: application/json are set:
$client->withOptions(['headers' => ['Accept' => 'application/json']]);
Custom Endpoints Extend the client to add missing endpoints:
class ExtendedEbisClient extends \Milestone\eBis\Client {
public function customEndpoint($params) {
return $this->request('GET', '/custom', $params);
}
}
Middleware Add request/response middleware:
$client->getHttpClient()->getEventDispatcher()->addListener(
'request',
fn($event) => $event->getRequest()->headers->set('X-Custom-Header', 'value')
);
Models If the package includes Eloquent models, extend them:
class CustomEbisModel extends \Milestone\eBis\Models\EbisModel {
protected $casts = ['created_at' => 'datetime:Y-m-d H:i:s'];
}
Service Providers Override bindings in a service provider:
$this->app->bind('ebis.client', fn() => new CustomEbisClient());
config('ebis.api_url')).config/ebis.php:
'timeout' => 30, // seconds
$client->withOptions(['verify_peer' => false]);
How can I help you explore Laravel packages today?