Download the PHP package premmohantyagi/apihub-laravel without Composer
On this page you can find all versions of the php package premmohantyagi/apihub-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download premmohantyagi/apihub-laravel
More information about premmohantyagi/apihub-laravel
Files in premmohantyagi/apihub-laravel
Package apihub-laravel
Short Description ApiHub for Laravel: one unified, driver-based interface over global third-party APIs covering payments, AI, email, SMS & messaging, and more.
License MIT
Homepage https://github.com/premmohantyagi/apihub-laravel
Informations about the package apihub-laravel
ApiHub for Laravel
ApiHub is a unified integration package for Laravel. It gives you one clean, consistent, driver-based interface over global third-party APIs (Payments, AI, Email, and SMS & Messaging) so you can swap providers with a config change instead of a rewrite.
Every driver is built on Laravel's HTTP client (no heavy vendor SDKs), so the package stays light and conflict-free while sharing one timeout/retry policy, a normalised response object, a unified exception hierarchy, secret redaction in logs, and webhook signature verification.
Table of contents
- Why ApiHub
- Requirements
- Installation
- Configuration
- Core concepts
- Drivers & facades
- Responses & the
raw()escape hatch - Error handling
- Testing with fakes
- Email
- Resend
- AI
- DeepSeek
- SMS & Messaging
- Discord
- Payments
- Authorize.Net
- Verifying webhooks
- Environment variables reference
- Development
- Roadmap
- License
Why ApiHub
- One interface per category. Swap Stripe for Razorpay, or OpenAI for Anthropic, by changing a config value, not your code.
- No SDK bloat. Drivers talk raw REST over
illuminate/http. Official SDKs are optional, never required. - Production-grade core. Retries, timeouts, mapped exceptions, redacted logging, and constant-time webhook verification are built in for free.
- Escape hatch always.
->raw()exposes the underlying response for provider-specific features the unified interface doesn't cover. - Test-friendly. Every category ships a fake (
Email::fake(),Ai::fake(),Sms::fake(),Payments::fake()) with assertions.
Requirements
- PHP 8.0 to 8.4
- Laravel 8, 9, 10, 11, 12, or 13
Installation
Install via Composer:
The service provider and the Payments, Ai, Email, and Sms facades are
auto-discovered, so no manual registration is needed.
Publish the config file:
This creates config/apihub.php. Add the credentials you need to your .env
(see Environment variables reference).
Configuration
Everything lives in a single config/apihub.php. Each category has a default
driver and a drivers array of per-provider credentials. Global HTTP, logging,
and queue settings apply to every driver.
When logging is enabled, every request is logged at debug level with any key
matching redact_keys masked, so credentials never reach the log channel.
Core concepts
Drivers & facades
Each category exposes a facade that resolves the default driver, or a
specific one via driver():
| Category | Facade | Default env | Drivers |
|---|---|---|---|
Email |
APIHUB_EMAIL_DRIVER |
mailgun, sendgrid, ses, resend |
|
| AI | Ai |
APIHUB_AI_DRIVER |
openai, anthropic, gemini, deepseek |
| SMS & Messaging | Sms |
APIHUB_MESSAGING_DRIVER |
twilio, vonage, msg91, telegram, whatsapp, slack, discord |
| Payments | Payments |
APIHUB_PAYMENTS_DRIVER |
stripe, razorpay, paypal, square, authorizenet |
Responses & the raw() escape hatch
Every result is a typed DTO with a consistent shape. The original provider payload is always available through the response:
Error handling
On a failed HTTP response, drivers throw a mapped exception. Catch the base class to handle any provider uniformly:
| Exception | HTTP status |
|---|---|
AuthenticationException |
401, 403 |
RateLimitException |
429 |
RequestException |
other 4xx |
ServerException |
5xx |
ApiHubException (base) |
anything else / catch-all |
Webhook verification and the fakes never throw on a bad signature or in tests; instead they return
falseor record the call.
Testing with fakes
Each category swaps in an in-memory implementation with assertions:
See each category below for its specific fake assertions.
EmailMessage validates that it has a from, at least one to, and an html
or text body before any driver sends it.
Attachments: Attachment::fromPath($path, $filename = null, $contentType = null)
or new Attachment($filename, $rawBytes, $contentType).
Testing
Mailgun
Posts to /v3/{domain}/messages with HTTP basic auth. Supports attachments
(multipart).
SendGrid
Posts JSON to /v3/mail/send with a bearer token. The message id is read from
the X-Message-Id response header.
Amazon SES
Sends a SigV4-signed request to the SES v2 API in your region.
Note: the SES driver currently sends "Simple" content. Attachments require a raw MIME body and are not yet supported; passing one throws an
InvalidArgumentException.
Resend
Posts JSON to /emails with a bearer token. The id is returned in the body.
AI
One ChatRequest works across every provider; the drivers translate it to each
API's shape, so switching providers is just ->driver('anthropic').
Testing
OpenAI
Chat Completions API (/v1/chat/completions), bearer auth.
Anthropic
Messages API (/v1/messages), x-api-key auth. The system prompt is sent as a
top-level field and max_tokens is always supplied (defaults to 1024).
Google Gemini
generateContent endpoint. The model goes in the path, the key is a query
param, and the system prompt becomes a systemInstruction.
DeepSeek
OpenAI-compatible Chat Completions API with the same request/response shape, just a different
endpoint and default model (deepseek-chat).
Default model names are sensible fallbacks only and overridable per driver via the
modelconfig key; pass->model(...)explicitly in production.
SMS & Messaging
Testing
Twilio
Posts form fields to the Messages resource with HTTP basic auth. Returns the
Twilio sid as the id.
Vonage
Posts to the Nexmo SMS API. Vonage returns HTTP 200 even on logical failure, so
acceptance is read from the per-message status (0 = success).
MSG91
Uses the plain-text HTTP endpoint (popular in India). The request id is returned as the response body.
Telegram
Posts JSON to /bot{token}/sendMessage; to is the chat id.
WhatsApp Business Platform (Cloud API) via the Graph API; bearer auth. to is
the recipient phone number.
Slack
Two modes, chosen by what you configure:
- a bot token uses
chat.postMessage(tois the channel; id is thets), - a webhook URL does a simple post (no id returned).
Discord
Two modes:
- a bot token + channel id (
to) uses the channel messages endpoint (returns id), - a webhook URL does an execute-webhook post (204, no body).
Payments
charge()semantics differ by gateway: it maps to each one's primary server-side call: Stripe creates+confirms a PaymentIntent; Razorpay and PayPal create an order (completed by the buyer); Square creates a payment; Authorize.Net runs an auth-capture. Theid,status, and->raw()let you continue each gateway's own flow.
Money: amounts are always in minor units (cents, paise). The Money
DTO formats decimals correctly, including zero-decimal currencies like JPY.
Testing
Stripe
Creates and confirms a PaymentIntent (form-encoded). Refunds act on the payment intent id.
Razorpay
charge() creates an Order (the payment is completed by the client checkout and
captured against this order). refund() acts on a payment id.
PayPal
Uses OAuth2 client-credentials for a bearer token. charge() creates an Orders
v2 order; refund() acts on a capture id.
Square
charge() creates a Payment from a card nonce (source). refund() refunds a
payment.
Authorize.Net
charge() runs an authCaptureTransaction against an Accept.js opaque-data
token (the source).
Verifying webhooks
Verify the signature against the raw request body (never a re-encoded array):
| Gateway | Verification |
|---|---|
| Stripe | HMAC-SHA256 over {timestamp}.{body} (Stripe-Signature: t=...,v1=...) |
| Razorpay | HMAC-SHA256 of the body (X-Razorpay-Signature) |
| Square | base64 HMAC-SHA256 over notification_url + body (x-square-hmacsha256-signature) |
| Authorize.Net | HMAC-SHA512 hex over the body (X-ANET-Signature: sha512=...) |
| PayPal | Calls PayPal's verify-webhook-signature API (needs webhook_id) |
Environment variables reference
Development
The package runtime supports PHP 8.0+ and Laravel 8+. The modern test tooling (Pest 2/3) needs PHP 8.1+, so CI runs the full suite across PHP 8.1 to 8.4 and Laravel 10 to 12, and additionally lints every source file under PHP 8.0 to guarantee it stays parse-compatible with the lowest supported version.
Roadmap
- [x] Core engine: HTTP connector, normalised responses, exception hierarchy, redaction, webhook verification, managers & facades.
- [x] Email: Mailgun, SendGrid, SES, Resend (+ AWS SigV4 signer).
- [x] AI: OpenAI, Anthropic, Gemini, DeepSeek.
- [x] SMS & Messaging: Twilio, Vonage, MSG91, Telegram, WhatsApp, Slack, Discord.
- [x] Payments: Stripe, Razorpay, PayPal, Square, Authorize.Net (+ webhook verification).
- [ ] Future categories (Cloud & Storage, Social, Maps, Auth, Monitoring) build on the same core without changes to it.
License
ApiHub for Laravel is open-source software licensed under the MIT license.
All versions of apihub-laravel with dependencies
guzzlehttp/guzzle Version ^7.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/queue Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0