PHPackages                             fenoandria/laravel-api-integration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. fenoandria/laravel-api-integration

ActiveLibrary[API Development](/categories/api)

fenoandria/laravel-api-integration
==================================

This is my package laravel-api-integration

01PHP

Since Sep 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/FenoAndria/laravel-api-integration)[ Packagist](https://packagist.org/packages/fenoandria/laravel-api-integration)[ RSS](/packages/fenoandria-laravel-api-integration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

API Integration Package for Laravel
===================================

[](#api-integration-package-for-laravel)

This package provides a flexible and extendable API client to interact with any external APIs by dynamically configuring base URLs, API keys, and handling HTTP requests. It's built for Laravel using Spatie's package template and is designed to integrate with various third-party services.

Features
--------

[](#features)

- **Dynamic Configuration** : Supports environment-based API configuration (base URL, API key).
- **Flexible HTTP Methods** : Allows GET, POST, PUT, DELETE requests with ease.
- **Extensible Design** : Easily add support for new APIs without altering the core package.
- **Service Container Integration** : Uses Laravel's service container for dependency injection and flexibility.
- **Mockable for Testing** : Easily test API responses with Guzzle mock handlers.

Installation
------------

[](#installation)

```
composer require fenoandria/laravel-api-integration:dev-main

```

### Publish the Configuration

[](#publish-the-configuration)

After installation, publish the configuration file:

```
php artisan vendor:publish --provider="FenoAndria\LaravelApiIntegration\LaravelApiIntegrationServiceProvider"

```

This will create the config/api-integration.php file, where you can set your API base URL and key.

Configure the .env file

Add your API credentials in your .env file:

- **API\_BASE\_URL** =
- **API\_KEY** = your-api-key

Usage
-----

[](#usage)

Via the Service Container

- You can inject the ApiClient into your services, controllers, or jobs via Laravel's service container:

```
$apiClient = app(ApiClient::class);

$response = $apiClient->get('your-endpoint', ['param' => 'value']);

dd($response);
```

- Manual Instantiation

For simple use cases, you can instantiate the ApiClient manually:

```
$apiClient = new ApiClient('https://api.yourservice.com', 'your-api-key');

$response = $apiClient->get('your-endpoint', ['param' => 'value']);

dd($response);
```

### Handling Requests

[](#handling-requests)

The ApiClient supports the common HTTP methods:

**GET request:**

```
$response = $apiClient->get('endpoint', ['param' => 'value']);
```

**POST request:**

```
$response = $apiClient->post('endpoint', ['param' => 'value']);
```

**PUT request:**

```
$response = $apiClient->put('endpoint', ['param' => 'value']);
```

**DELETE request:**

```
$response = $apiClient->delete('endpoint');
```

### Testing

[](#testing)

The package includes PHPUnit tests. To run tests, ensure that you have a .env.testing file configured if your package relies on environment variables.

You can mock HTTP requests using Guzzle's mock handler in your tests. Here's an example:

```
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\HandlerStack;
use FenoAndria\LaravelApiIntegration\Services\ApiClient;

$mock = new MockHandler([
    new Response(200, [], json_encode(['data' => 'mocked data']))
]);

$handlerStack = HandlerStack::create($mock);
$httpClient = new \GuzzleHttp\Client(['handler' => $handlerStack]);

$apiClient = new ApiClient('https://api.mockservice.com', 'mock-api-key', $httpClient);

$response = $apiClient->get('endpoint');

$this->assertEquals('mocked data', $response['data']);
```

Extending the Package
---------------------

[](#extending-the-package)

You can extend this package to support additional APIs by adding more methods or modifying the existing service class to suit your needs.

Contributing
------------

[](#contributing)

Feel free to fork this package and contribute by submitting pull requests. Any suggestions for improvements are welcome! License

This package is open-sourced software licensed under the MIT license.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6a766049cd9edf368058598bfbf24d36e187b227ecd7be8dabaf4e26346b2c0?d=identicon)[FenoAndria](/maintainers/FenoAndria)

---

Top Contributors

[![FenoAndria](https://avatars.githubusercontent.com/u/102666055?v=4)](https://github.com/FenoAndria "FenoAndria (7 commits)")

### Embed Badge

![Health badge](/badges/fenoandria-laravel-api-integration/health.svg)

```
[![Health](https://phpackages.com/badges/fenoandria-laravel-api-integration/health.svg)](https://phpackages.com/packages/fenoandria-laravel-api-integration)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
