Download the PHP package solanaguide/laravel-x402 without Composer

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

x402 Payment Middleware for Laravel & Symfony — gate routes behind instant USDC micropayments on Solana.

The x402 protocol revives HTTP 402 (Payment Required) to enable automatic, instant payments over HTTP. This package lets you protect any route with a single middleware call — AI agents and API consumers pay per-request in USDC on Solana.

Features

Requirements

Installation

Laravel

The service provider is auto-discovered. Publish the config:

Symfony

Register the bundle in config/bundles.php:

Setup

1. Configure environment

2. Initialize the pay-to wallet

Your X402_PAY_TO wallet must have an active USDC token account before it can receive payments. If the wallet has never held USDC, the token account won't exist and payments will fail.

To initialize it, send a small amount of USDC (e.g., $0.01) to the wallet from:

This automatically creates the Associated Token Account.

3. Verify your setup

This command validates your configuration and checks on-chain that the token account exists. Run it before going live.

Configuration

Full Config Options

Variable Default Description
X402_PAY_TO (required) Solana address to receive payments
X402_ASSET USDC mainnet mint Token mint address
X402_NETWORK solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp CAIP-2 network ID
X402_SCHEME exact Payment scheme
SOLANA_RPC_URL https://api.mainnet-beta.solana.com Solana RPC endpoint
SOLANA_COMMITMENT confirmed Commitment level
SOLANA_RPC_TIMEOUT 30 RPC timeout (seconds)
SOLANA_CONFIRM_RETRIES 30 Confirmation poll attempts
SOLANA_CONFIRM_INTERVAL 500 Ms between confirmation polls
X402_AI_CRAWLER_PRICE false Price to charge AI crawlers (e.g., 0.001)
X402_MAX_TIMEOUT_SECONDS 60 Max payment timeout
X402_DESCRIPTION (empty) Default payment description
X402_MIME_TYPE application/json Default response MIME type

Usage

Laravel — Middleware Parameter (Simplest)

Laravel — Config-Based Pricing

Symfony — Route Attribute

How It Works

  1. Client sends a request to a gated route
  2. If no PAYMENT-SIGNATURE header is present, the middleware returns HTTP 402 with a PAYMENT-REQUIRED header containing payment details (amount, recipient, token, network)
  3. Client constructs and signs a Solana SPL Token transfer transaction
  4. Client retries the request with the signed transaction in the PAYMENT-SIGNATURE header
  5. The middleware:
    • Deserializes the Solana transaction
    • Verifies the SPL Token transfer instruction (recipient, amount, token mint)
    • Verifies Ed25519 signatures
    • Submits the transaction to Solana via RPC
    • Polls for confirmation
  6. On success, the original content is served with a PAYMENT-RESPONSE header containing the transaction hash

402 Response Format

SpherePay Integration

For automatic fiat conversion, create a SpherePay account and set your offramp Solana address as the pay-to address:

All USDC payments are automatically converted to fiat and deposited to your bank account. No code changes needed.

Charging AI Crawlers

AI bots like GPTBot, ClaudeBot, and PerplexityBot scrape your content for training and retrieval. With x402, you can keep your content free for humans while charging AI crawlers automatically.

Then add the x402 middleware globally or to your web routes (without a price parameter):

Human visitors browse your site for free. AI crawlers get a 402 response with payment instructions. If they pay, they get the content.

Routes with an explicit price (x402:0.01) always charge that price regardless of the crawler setting.

The package detects 70+ known AI user agents across categories — agents, assistants, data scrapers, search crawlers, and undocumented bots. The full list is sourced from knownagents.com and includes GPTBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, PerplexityBot, DeepSeekBot, Google-Extended, Bytespider, CCBot, Amazonbot, meta-externalagent, OAI-SearchBot, Manus-User, and many more.

Note: The x402 protocol is in its early days. Most AI crawlers today will not pay — they'll simply receive the 402 and move on. Setting a crawler price effectively blocks non-paying bots while laying the groundwork for a future where crawlers are expected to pay for content access.

Add custom patterns:

Testing

Or directly:

Architecture

Credits

License

MIT License. See LICENSE for details.


All versions of laravel-x402 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-sodium Version *
tuupola/base58 Version ^2.1
illuminate/support Version ^10.0|^11.0|^12.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 solanaguide/laravel-x402 contains the following files

Loading the files please wait ...