Download the PHP package johnguoy/laravel-x402 without Composer

On this page you can find all versions of the php package johnguoy/laravel-x402. 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 laravel-x402

laravel-x402

Latest Version on Packagist Tests Total Downloads

laravel-x402 is a Laravel SDK for the x402 V2 HTTP payment protocol. Protect any API route with a single middleware line and start collecting USDC micropayments from AI agents and developer clients — no accounts, no API keys, no subscriptions.

Requirements

Dependency Version
PHP ^8.2
Laravel ^11.0 | ^12.0 | ^13.0
BCMath extension enabled (standard in PHP 8.x)

Installation

Laravel's package auto-discovery will register the service provider and X402 facade automatically.

Publish the config file

This creates config/x402.php in your application where you configure your wallet, networks, and facilitators.

Configuration

Open config/x402.php (or set environment variables in .env):

Minimal .env for development (testnet)

Minimal .env for production (Base Mainnet)


Usage

1. Protect a route with the x402 middleware

Middleware parameter order:

All parameters after price are optional and fall back to config values.


2. What clients receive

Step 1 — request without payment (402 response):

Step 2 — request with payment signature (200 response):


3. Use the Facade for advanced scenarios

4. Use PaymentAmount for precision math


Networks & Facilitators

Supported Networks (CAIP-2)

Network CAIP-2
Base Mainnet eip155:8453
Base Sepolia (testnet) eip155:84532
Ethereum Mainnet eip155:1
Polygon Mainnet eip155:137
Avalanche C-Chain eip155:43114
Solana Mainnet solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
Solana Devnet solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1

Known Production Facilitators

Key URL Notes
coinbase https://facilitator.cdp.coinbase.com KYT/OFAC checks
cloudflare https://x402.cloudflare.com Edge-native
stellar https://facilitator.stellar.org Stellar network only
dexter https://facilitator.dexter.cash Free, no account
mogami https://facilitator.mogami.tech Free, Base focused
testnet https://x402.org/facilitator Dev/testnet only

Testing

Run only unit or feature tests:


Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.md.

Credits


All versions of laravel-x402 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/routing Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8
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 johnguoy/laravel-x402 contains the following files

Loading the files please wait ...