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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apihub-laravel

ApiHub for Laravel

tests Latest Version

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

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 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 false or 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.


Email

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 model config 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

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:

Discord

Two modes:


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. The id, 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


License

ApiHub for Laravel is open-source software licensed under the MIT license.


All versions of apihub-laravel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
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
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package premmohantyagi/apihub-laravel contains the following files

Loading the files please wait ...