Skip to content

Laragear/Expose

Repository files navigation

Expose

Latest Version on Packagist Latest stable test run Codecov coverage Maintainability Sonarcloud Status

Expose your application to the Internet in one command

composer expose

Become a sponsor

Your support allows me to keep this package free, up to date, and maintainable.

Requirements

  • Linux or macOS (Windows may work)
  • PHP 8.3 or later
  • Composer 2.6 or higher
  • A PHP project with a composer.json at the root

Installation

You can install the package via Composer.

composer require global laragear/expose

How does this work?

This composer plugin manages popular tunneling services to expose your application on the Internet. This is great when you want to show your application development to somebody far away, through a simple link, especially when dealing with live-client videocalls or meetings.

Supported Tunnel Services

Service Key Distributed as Auth required
ngrok ngrok Binary (cURL) Optional (free tier)
Cloudflare Tunnel cloudflare Binary (cURL) Optional (quick tunnels)
InsTunnel instatunnel NPM package Optional
Localtunnel localtunnel NPM package No
Pinggy pinggy SSH (system binary) Optional
Zrok zrok Binary (cURL) Yes (free account)

Usage

To expose your application to the Internet, simple use composer expose:

composer expose

On the first run, the command will:

  1. Detect your PHP framework (Laravel, Symfony, WordPress, CakePHP, Yii, Lumen, or plain PHP).
  2. Ask which tunnel service you prefer, then save the choice to composer.json.
  3. Check that the tunnel binary is installed; download it or guide you through manual installation if not.
  4. Run a local development server on http://localhost:8080 (or the preferreded by your app).
  5. Start the tunnel and print the public URL.

The are some options you can use when exposing your application:

Option Short Description
--host Local host to bind to (default: localhost)
--port -p Local port to bind to (default: 8080)
--tunnel -t Override the tunnel service for this run only

For example, you can use ngrok using an alternative host and port.

composer expose --port=9000
composer expose --tunnel=cloudflare

Updating tunnels

To update the tunnel library, or only one given tunnel, use the expose:update command.

composer expose:update
composer expose:update --force          # Force re-download
composer expose:update --tunnel=ngrok   # Target a specific service

Configuring tunnels

The expose:configure command will walk you through service-specific prompts (auth tokens, subdomains, regions, etc.) to properly configure the tunnel you're using.

composer expose:configure
composer expose:configure --reset       # Clear saved tunnel preference

Tip

Sensitive values like auth tokens are never set in the composer.json.

Checking tunnel status

To display whether the tunnel is running, the current public URL, and the connection count (where available), use the expose:status command.

composer expose:status

Uninstall tunnel binaries

The expose:uninstall command will uninstall all tunnel binaries. It does not uninstall the plugin.

composer expose:uninstall
composer expose:uninstall --purge       # Also remove all Expose config from composer.json

Adding additional tunnels

You may be not happy with the current selection of tunnels. In that case, you can add your own tunnel in your extra.expose key in your composer.json.

The tunnel should state the default tunnel, and the tunnels should describe your tunnels labels and class.

{
    "extra": {
        "expose": {
            "tunnel": "my-vpn",
            "tunnels": {
                "my-vpn": {
                    "label": "My Corporate VPN Tunnel",
                    "class": "App\\DevTools\\CorpVpnTunnel"
                }
            }
        }
    }
}

The CorpVpnTunnel class must implement Laragear\Expose\Contracts\Tunnel (or extend AbstractTunnel which may be easier):

namespace App\DevTools;

use Laragear\Expose\Tunnels\AbstractTunnel;
use Symfony\Component\Process\Process;

class CorpVpnTunnel extends AbstractTunnel
{
    public function name(): string 
    { 
        return 'Corporate VPN';
    }

    public function binary(): string
    {
        return 'vpntunnel';
    }

    public function start(string $host, int $port): Process
    {
        $process = $this->buildProcess([
            $this->binaryCommand(), '--local', "{$host}:{$port}",
        ]);
        
        $process->start();
        
        return $process;
    }
}

Adding a tunnel via package

If you're a package author, you can also make your package a tunnel-provider by offering your own adapter through the extra.expose-tunnel key.

{
    "name": "acme/my-tunnel",
    "extra": {
        "expose-tunnel": {
            "key":   "acme",
            "label": "Acme Tunnel (acme.example.com)",
            "class": "Acme\\Tunnel\\AcmeTunnel"
        }
    }
}

Configuration

You can publish the configuration through vendor:publish:

php artisan vendor:publish --provider="Laragear\Expose\ExposeServiceProvider" --tag="config"

You should receive a file with an array like this:

return [
    // ...
]

Security

If you discover any security-related issues, issue a Security Advisory.

License

This specific package version is licensed under the terms of the MIT License, at the time of publishing.

Laravel is a Trademark of Taylor Otwell. Copyright © 2011-2026 Laravel LLC.

About

Expose your local PHP project to the internet via popular tunnel services.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors