PHPackages                             nedwors/hopper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. nedwors/hopper

ActiveLibrary[Database &amp; ORM](/categories/database)

nedwors/hopper
==============

Hopper lets you move between your local Laravel databases with ease, preserving data and easing development

0.2.0(5y ago)52107[1 issues](https://github.com/nedwors/hopper/issues)MITPHPPHP ^7.4|^8.0

Since Mar 5Pushed 5y ago2 watchersCompare

[ Source](https://github.com/nedwors/hopper)[ Packagist](https://packagist.org/packages/nedwors/hopper)[ Docs](https://github.com/nedwors/hopper)[ RSS](/packages/nedwors-hopper/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

[![](https://camo.githubusercontent.com/ea3217bda98fdc655dcbbeef9efd7d2fae0a4cd89b205cdc48a633354bed71f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f486f707065722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6e6564776f7273253246686f707065722b2d2d646576267061747465726e3d706965466163746f7279267374796c653d7374796c655f31266465736372697074696f6e3d266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6461746162617365)](https://camo.githubusercontent.com/ea3217bda98fdc655dcbbeef9efd7d2fae0a4cd89b205cdc48a633354bed71f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f486f707065722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6e6564776f7273253246686f707065722b2d2d646576267061747465726e3d706965466163746f7279267374796c653d7374796c655f31266465736372697074696f6e3d266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d6461746162617365)

Hopper
======

[](#hopper)

[![Tests](https://github.com/nedwors/hopper/workflows/Tests/badge.svg)](https://github.com/nedwors/hopper/workflows/Tests/badge.svg)

Hop between databases with ease whilst developing locally on Laravel.

Imagine: A colleague asks you to check their PR out. But you're working on a new feature yourself and your local database is \*just\* right. You've got it tuned with the right models, the right data - losing it would just be an inconvenience too far...

So now imagine: A colleague asks you to check their PR out. You jump onto their branch, set up your database - migrate it, seed it, wipe it, whatever - and review their work. Then, you return to your feature and pick up where you left off - *with your database still intact*.

Enter Hopper. It's as simple as:

```
php artisan hop awesome_new_feature
```

Now, you're on a database called `awesome_new_feature`.

With Git, it's even simpler:

```
php artisan hop
```

Now, you're on a database for the current branch!

And you can always hop back to your default database with:

```
php artisan hop --d
```

Now, you're on the default database as configured by your Laravel settings.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require nedwors/hopper --dev
```

Setup
-----

[](#setup)

Hopper comes with a config file for you to publish to `config/hopper.php`:

```
php artisan hop:publish
```

> You don't need to publish the config file to use Hopper, but it is recommended. But no pressure. Honest... See [configuration](#configuration) to see whether you want to for your project.

Usage
-----

[](#usage)

Commands:

- [hop](#hop)
- [hop:current](#hopcurrent)
- [hop:delete](#hopdelete)

Configuration:

- [Default Git Branch](#default-git-branch)
- [Connections](#connections)
    - [Sqlite](#sqlite)
    - [MySql](#mysql)
    - [Adding Your Own](#adding-your-own)
- [Boot Checks](#boot-checks)
- [Post Creation Steps](#post-creation-steps)

### Commands

[](#commands)

### hop

[](#hop)

This is the core command when using Hopper. There are 3 ways it can be used:

- Use a database for the current Git branch
- Use a specific database
- Use the default database

#### Using a database for the current Git branch

[](#using-a-database-for-the-current-git-branch)

This option is where Hopper really shines. Simply checkout a branch, hop, and you're on a new database. Checkout your previous branch, hop, and you're back to where you started.

To use Hopper this way, simply hop without arguments:

```
git checkout -b updates

php artisan hop
```

Now, when using your app, it will be connected to the `updates` database.

Your default Git branch aliases to your default database. So, imagine `main` is your default branch. When you run this:

```
git checkout main

php artisan hop
```

You won't move to the a database called `main`. Instead, you'll be moved to your default database - simple!

But don't worry, you're not forced to use the current Git branch. You can also specify a name at any point, or manually use the default branch.

#### Using a specific database

[](#using-a-specific-database)

To use a specific database, simply pass the name of the database to use:

```
php artisan hop foobar
```

Now, when using your app, it will be connected to the `foobar` database.

#### Using the default database

[](#using-the-default-database)

To use the default database, pass the `--d` option to the command:

```
php artisan hop --d
```

Now, your app simply uses the default database as is set up in Laravel.

> Hopper steps aside when the default database is used; it doesn't touch your database connection. This is useful for team members who might not want to use Hopper themselves. They can rest assured that Hopper isn't interfering with their setup.

#### Post Creation

[](#post-creation)

When it is the first time using a database, Hopper will create it ready to use. Likely, you'll want to migrate and setup up this database. Hopper provides a clean way to run Post Creation Steps - [see how you can set these up](#post-creation-steps).

### hop:current

[](#hopcurrent)

See the database that you are currently using:

```
php artisan hop test

php artisan hop:current

// Currently using test
```

### hop:delete

[](#hopdelete)

Delete the given database:

```
php artisan hop:delete test

// Deleted test
```

When a database is deleted, you will be moved back to your default database.

### Configuration

[](#configuration)

As stated in [setup](#setup), you don't need to publish the hopper config file to use Hopper. The config file is as so:

```
'default-branch' => env('HOPPER_DEFAULT_BRANCH', 'main'),

'connections' => [
    'sqlite' => [
        'driver' => Sqlite::class,
        'database-path' => 'hopper/'
    ],
    'mysql' => [
        'driver' => MySql::class,
        'database-prefix' => 'hopper_'
    ],
],

'boot-checks' => [
    Environment::class
],

'post-creation-steps' => [
    'migrate:fresh'
]
```

We'd encourage to checkout all the options described below to see if you want to publish it or not.

### Default Git Branch

[](#default-git-branch)

You should define here the name of the default git branch in your project:

```
...

'default-branch' => env('HOPPER_DEFAULT_BRANCH', 'main')

...
```

Now, every time you [hop](#hop) on this branch without arguments, your default database will be used automatically - rather than a database called `main`.

You'll see that there is a `HOPPER_DEFAULT_BRANCH` `.env` variable available too - this means you can alter this value without publishing the config file.

### Connections

[](#connections)

Currently, Hopper has built in support for `sqlite` and `mysql` database connections. Hopper will automatically use whichever connection you are using.

These and future drivers are exposed and configured in the config file - which means you can add your own even if Hopper doesn't yet support it natively! See the supported connections in `hopper.php`:

```
...

'connections' => [

    'sqlite' => [
        'driver' => Sqlite::class,
        'database-path' => 'hopper/'
    ],

    'mysql' => [
        'driver' => MySql::class,
        'database-prefix' => 'hopper_'
    ],

]

...
```

#### Sqlite

[](#sqlite)

Hopper stores all Sqlite databases within a relative directory in the database directory of your application. You can configure the name of the directory in the config file:

```
...

'connections' => [

    'sqlite' => [
        'driver' => Sqlite::class,
        'database-path' => 'hopper/'
    ],

]

...
```

So, as you might expect, all temporary databases created by Hopper will be stored in `database/hopper/`. So for example, running this command...

```
php artisan hop test
```

...will create a sqlite database at `database/hopper/test.sqlite`.

> The `hopper` directory will be created by Hopper if it doesn't already exist

> All database names passed to hopper when using Sqlite will be sanitized. Slashes will be automatically converted to dashes for the Sqlite connection. So for instance, `hop this/database` will create a database called `this-database.sqlite`

> It's probably worth adding your chosen directory to your `.gitignore` when using the `sqlite` connection!

#### MySql

[](#mysql)

Hopper creates all MySql databases on your configured MySql connection. All databases created will have a prefix applied to their name so you can easily identify them as needed. You can configure the prefix in the config file:

```
...

'connections' => [

    'sqlite' => [
        'driver' => MySql::class,
        'database-prefix' => 'hopper_'
    ],

]

...
```

So for example, running this command...

```
php artisan hop test
```

...will create a MySql database called `hopper_test`.

> All database names passed to hopper when using MySql will be sanitized. Dashes will be automatically converted to underscores for the MySql connection. So for instance, `hop this-database` will create a database called `hopper_this_database`

#### Adding your own

[](#adding-your-own)

Hopper makes it nice and easy to add your own connection for a database type this is supported by Laravel but not by Hopper.

To add your own connection, create a class that implements the `Connection` interface. You can refer to the existing connections to see how to build your new implementation. When you are ready to implement it, add it to the connections array:

```
...

'connections' => [

    ...

    'newconnection' => [
        'driver' => NewConnection::class
    ],

    ...

]

...
```

### Boot Checks

[](#boot-checks)

Hopper exposes the checks it runs prior to wiring up your database connection. This way, you can alter the existing checks and/or add your own if needed. They are found in the `hopper.php` config file:

```
...

'boot-checks' => [
    Environment::class
]

...
```

The included `Environment` check ensures the app environment is `local`. To add your own, ensure your class either implements the `BootCheck` interface or exposes a `check()` method which returns a `boolean`. Then, pop the class name in this array and you're all set.

### Post Creation Steps

[](#post-creation-steps)

It is super simple to configure the steps you want to run after creating a new database.

The steps can be found in the `hopper.php` config file:

```
...

'post-creation-steps' => [
    'migrate:fresh --seed'
]

...
```

All strings included in this array must refer to an Artisan command in your app.

Closures can also be defined:

```
...

'post-creation-steps' => [
    'migrate:fresh',
    fn() => app(SpecificDatabaseSeeder::class)->run()
]

...
```

> All steps are run in order of declaration, so ensure you `migrate` your database before any seeders!

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Sam Rowden](https://github.com/nedwors)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

1896d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8581f7aef8679c8f7501cd36239817172bd23a8c83804055f41c73b44e93642f?d=identicon)[nedwors](/maintainers/nedwors)

---

Top Contributors

[![nedwors](https://avatars.githubusercontent.com/u/59183434?v=4)](https://github.com/nedwors "nedwors (175 commits)")[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (2 commits)")[![andreich1980](https://avatars.githubusercontent.com/u/17148882?v=4)](https://github.com/andreich1980 "andreich1980 (1 commits)")

---

Tags

laraveldatabasemysqlsqlitenedworshopper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nedwors-hopper/health.svg)

```
[![Health](https://phpackages.com/badges/nedwors-hopper/health.svg)](https://phpackages.com/packages/nedwors-hopper)
```

###  Alternatives

[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)[boxed-code/laravel-scout-database

Generic database driver for laravel scout.

1151.7k](/packages/boxed-code-laravel-scout-database)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
