PHP code example of getxpos / laravel

1. Go to this page and download the library: Download getxpos/laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

getxpos / laravel example snippets


use GetXPOS\Laravel\Facades\Xpos;

$tunnel = Xpos::connect(['port' => 8000]);
echo $tunnel->url; // https://abc123.xpos.to
$tunnel->close();

use GetXPOS\Laravel\Facades\Xpos;

$tunnel = Xpos::connect(['port' => 8000]);

echo $tunnel->url;       // https://abc123.xpos.to
echo $tunnel->expiresAt; // 2026-03-28T10:30:45Z

$tunnel->close();

$tunnel = Xpos::connect([
    'port' => 8000,
    'token' => 'tk_your_token',
    'subdomain' => 'myapp',
]);
// https://myapp.xpos.to

use GetXPOS\Laravel\XposTunnel;

$tunnel = XposTunnel::connect(['port' => 8000]);
echo $tunnel->url;
$tunnel->close();

use GetXPOS\Laravel\Facades\Xpos;

// In your test setup
$tunnel = Xpos::connect(['port' => 8000, 'token' => 'tk_xxx']);

// Configure Stripe to send webhooks to your tunnel
$stripe = new \Stripe\StripeClient('sk_test_xxx');
$stripe->webhookEndpoints->create([
    'url' => $tunnel->url . '/api/webhooks/stripe',
    'enabled_events' => ['payment_intent.succeeded'],
]);

// Run your tests...

$tunnel->close();

use GetXPOS\Laravel\XposTunnel;

$tunnel = new XposTunnel(['port' => 8000]);

$tunnel->onConnect(function (array $info) {
    echo "Connected: {$info['url']}\n";
    // $info['expiresAt'] may be null for paid plans
});

$tunnel->onClose(function (?int $exitCode) {
    echo "Tunnel closed (exit: {$exitCode})\n";
});

$tunnel->onOutput(function (string $data) {
    // Raw SSH output
});

$tunnel->start();

// Block until process exits
$tunnel->wait();

use GetXPOS\Laravel\Facades\Xpos;

$tunnel = Xpos::connect([
    'mode' => 'tcp',
    'port' => 5432,
    'token' => 'tk_xxx',
]);

echo $tunnel->url; // myapp.xpos.to:34567

$tunnel->close();
bash
php artisan xpos
bash
# Expose PostgreSQL
php artisan xpos --mode=tcp --port=5432 --token=tk_xxx

# Expose Redis
php artisan xpos --mode=tcp --port=6379 --token=tk_xxx

# Expose MySQL
php artisan xpos --mode=tcp --port=3306 --token=tk_xxx
bash
php artisan vendor:publish --tag=xpos-config
bash
php artisan xpos --port=8001