Download the PHP package phattarachai/laravel-db-tunnel without Composer

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

Laravel DB Tunnel

Latest Version on Packagist Tests Code Style PHP Version Laravel Version Total Downloads

Reach remote databases (production, UAT, QAS) from your local Laravel app through SSH, so their ports never have to be open to the internet.

The main use case is giving Laravel Boost read-only claude-* connections, so an AI agent can investigate real data on remote environments. It also handles an app whose own database lives behind a tunnel.

Command Purpose
db:tunnel status [conn] A table of every tunnel: local port, SSH alias → remote, open / closed / port held by another process.
db:tunnel open <conn> · open --all Open detached tunnels and wait until they listen.
db:tunnel close <conn> · close --all Kill the ssh process listening on the tunnel's port, and nothing else.
db:tunnel install [conn] Allocate a machine-wide free port and write <ENV>_DB_PORT to .env.
db:tunnel doctor [--prune] Report port collisions across projects, ~/.ssh/config and listening sockets, plus per-tunnel problems.
db:tunnel watch <conn> Foreground supervisor: dial, watch, re-dial. For composer dev.
db:tunnel wait <conn> [--timeout=60] Block until the tunnel listens. Use it to gate serve / queue panes.

Requirements

Installation

With Laravel Boost installed, run php artisan boost:update (or boost:install) and select this package to get its agent skill.

Quick start: a read-only production connection for Boost

1. Add a connection in config/database.php. The port is machine-specific, so it has no default. Neither does the password.

2. Describe the tunnel in config/db-tunnel.php, keyed by the same connection name:

3. Allocate a port:

4. Query. DB::connection('claude-prod'), php artisan db:show --database=claude-prod, or Boost's database-query with database: claude-prod all open the tunnel on first use. Check with php artisan db:tunnel status.

How it works

Ports

The local end of each tunnel is the connection's own port. That keeps config/database.php as the single source of truth, which matters because tools such as the Boost MCP server read it once at boot.

db:tunnel install picks the port once and keeps it stable. It considers a port taken when any of these hold it:

Install then decides in this order:

  1. It reuses the port already registered for this project and connection.
  2. Otherwise it adopts the current .env port, if that port is inside port_range (default 15440–15999) and free.
  3. Otherwise it takes the first free port in the range.

If a registered port has since been taken by someone else, install moves the connection to a fresh port. Pin a port with --port=15444.

.env.example gets an empty <ENV>_DB_PORT=, because each machine allocates its own.

Opening and closing

open runs:

It then waits until the port is actually listening. If the alias already declares a LocalForward for that port, -L is left out and plain ssh -f -N <alias> is used, so dedicated tunnel aliases keep working.

ControlMaster=no and ControlPath=none keep the tunnel out of SSH connection multiplexing. Without them, an alias with ControlMaster auto and a live master connection would hand the -L forward to that master process and exit, so the port would be held by ssh: … [mux] instead of a tunnel db:tunnel recognises. The tunnel always gets its own connection, whatever the alias sets; your interactive ssh <alias> sessions keep multiplexing as before.

Tunnel state comes from the process that listens on the port (lsof/ss), not from a connect probe. A connect probe such as nc -z reports ports open on WSL2 that nothing is listening on. The listener check tells three cases apart:

close kills only an ssh listener to the right alias.

Auto-open

When db-tunnel.auto_open is null (the default), tunnels open automatically in APP_ENV=local. The package registers a connection resolver for each tunneled connection. That resolver opens the tunnel, if needed, the moment Laravel resolves the connection. A failure throws a TunnelException that carries ssh's own error message.

Set 'auto_open' => false on a tunnel, or DB_TUNNEL_AUTO_OPEN=false, to turn this off.

The app's own database behind a tunnel

When the default connection itself goes through SSH, supervise the tunnel inside composer dev rather than detaching it. Also set 'auto_open' => false on that tunnel.

watch does the following:

Anything network-specific, such as bringing a VPN up first, stays in the project's own dev script.

A read-only role on the server

The claude-* role should only ever SELECT. Tunnelled connections arrive from the server's own loopback.

PostgreSQL:

MySQL / MariaDB:

Keep the password in .env only. Never put it in an env() default in committed config.

Configuration

If the alias is missing from ~/.ssh/config, open and install print a login block to add:

Testing

Changelog

See the Releases page.

License

The MIT License (MIT). See LICENSE.md.


All versions of laravel-db-tunnel with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/process Version ^12.0|^13.0
illuminate/support Version ^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 phattarachai/laravel-db-tunnel contains the following files

Loading the files please wait ...