Download the PHP package envor/laravel-managed-databases without Composer
On this page you can find all versions of the php package envor/laravel-managed-databases. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download envor/laravel-managed-databases
More information about envor/laravel-managed-databases
Files in envor/laravel-managed-databases
Package laravel-managed-databases
Short Description A small package for managing multiple databases and their connections at runtime using laravel tools.
License MIT
Homepage https://github.com/envor/laravel-managed-databases
Informations about the package laravel-managed-databases
A small package for managing multiple databases and their connections at runtime using laravel tools
Installation
You can install the package via composer:
Usage
createDatabase()
runOnDatabase()
configureDatabase()
ManagedDatabases::createDatabase()
The createDatabase()
method will
- Cache the current default database connection config
- Set the connection to the
$managerConnection
- Purge the connection and reconnect
- Create the physical database
- Purge the connection
- Restore original default connection
- Purge and reconnect
[!TIP] The
$managerConnection
must exist and be a configured database connection.
This package creates a few defaults:manager_sqlite
,manager_mysql
andmanager_mariadb
.
They are bootstrapped into memory by cloning the default configs forsqlite
,mysql
andmariadb
.
ManagedDatabases::runOnDatabase()
The runOnDatabase()
method will connect the given $database
using a new connection created with the credentials and options from the given $managerConnection
, execute the given $callback
, then finally, restore the original default database connection.
- Cache the current default database connection config
- Create a new connection config for the database by cloning the
$managerConnection
config - Set the database as default and connect to it
- Run the given callback
- Purge the connection
- Restore original default connection
- Purge and reconnect
The package also includes an artisan
wrapper for the runOnDatabase()
method called managed-databases:run
.
The simplest and most harmless way to check it out is by pasting the following command into your terminal:
This will run your migrations and seeders harmlessly against an in-memory sqlite database. A great way to quickly check if they can run without errors.
ManagedDatabases::configureDatabase()
The configureDatabase()
method will set the given database as the default on on a brand new connection modeled after the given $managerConnection
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- inmanturbo
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-managed-databases with dependencies
envor/laravel-schema-macros Version ^1.1
illuminate/contracts Version ^11.0
spatie/laravel-package-tools Version ^1.16.2