Download the PHP package michaeljennings/refresh-database without Composer

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

Refresh Database Build Status Latest Stable Version Coverage Status

When running database tests in laravel one of the biggest overheads is running all of your migrations, the bigger your application gets the longer it takes.

This package speeds up your tests by running the migrations once into an sqlite file, then before each test rather than running migrations it loads the database structure from a database dump.

At the minute this package only works with phpunit and sqlite.

Version Compatibility

Laravel Refresh Database
5.x 1.x
6.x 1.x
7.x 2.x

Installation

To install the package run:

Or add michaeljennings/refresh-database to the require-dev section of your composer.json.

Then run composer update to install the package.

Usage

Firstly we need to tell phpunit to bootstrap from the package bootstrap.php file.

By default the bootstrapper will look for a config file called .refresh-database.yml at the same level as your vendor directory.

So your project may looks something like this:

In the .refresh-database.yml you can define the directories we should load migrations from and where the directory to store the database dump in.

A simple config file will look like the following:

When you run your tests we will create a .database directory in the output directory. All of the migrations will be run into a sqlite database and then a database dump will be taken for the database structure.

Once you have your config setup you then just need to use the MichaelJennings\RefreshDatabase\RefreshDatabase trait in your test or test case.

Multiple Connections

Some systems require you to run migrations into multiple databases, e.g. a multi-tenanted system.

To migrate to multiple database connections you can set the connections property in your .refresh-database.yml file.

Below is a config file with two database connections; shared, and tenant.

The connection key must be the name of a database connection in your laravel app.

For the config file above you would have to set two database connections; one called shared, and another called tenant.

Service Providers

In your application you may have migrations that rely on a service provider being registered, because this package creates it's own application instance you will need to tell it which service providers to register.

To register your service providers you set the providers property in your .refresh-database.yml file.

Below is an example config file where we are loading a utility service provider.

Environments

Occasionally you might find you to want to disable the database dump in certain environments.

To disable the database dump you can set a DUMP_DATABASE environment variable and set it to false.

Migration Cache

By default this package will cache the contents of your migrations so that it only rebuilds the database if it needs to.

If you want to rebuild the database each time you run your tests you set the cache_migrations property to false in your .refresh-database.yml file.

If you have setup multiple database connections you only need to specify the cache_migrations property once.

If you find the package is not rebuilding the database when you think it should be delete the .database directory from your output directory.


All versions of refresh-database with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
illuminate/support Version >=7.0
orchestra/testbench Version >=7.0
symfony/yaml Version >=5.0
symfony/process Version >=5.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 michaeljennings/refresh-database contains the following files

Loading the files please wait ....