Download the PHP package envor/laravel-database-manager without Composer
On this page you can find all versions of the php package envor/laravel-database-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download envor/laravel-database-manager
More information about envor/laravel-database-manager
Files in envor/laravel-database-manager
Package laravel-database-manager
Short Description A small library for managing databases.
License MIT
Homepage https://github.com/envor/laravel-database-manager
Informations about the package laravel-database-manager
Abondoned! Use https://github.com/envor/laravel-schema-macros instead
A small library for managing databases
Create and delete mysql
and sqlite
databases. Soft deletes, or "recycles" databases by default. Also it can clean up old recycled databases.
Installation
You can install the package via composer:
[!WARNING]
If you are using laravel 10, you will have to manually install doctrine/dbal
doctrine/dbal is not a requirement for Laravel 11
You can publish the config file with:
This is the contents of the published config file:
Usage
Faking
This package tests things like creating and deleting physical databases so that you don't have to. You simply call DatabaseManager::fake()
then test your application's feature logic (validation, etc)
SQLite
Creates an sqlite database at storage/app/my-new-database.sqlite
Soft deletes the database and moves it to storage/app/.trash/2023/03/02/07_04_38_my-new-database.sqlite
:
The package appends the .sqlite file extension on its own, and expects managed sqlite database files to have the extension
Erases the database permanently from disk:
Erases all the database files in the .trash folder with mtime more than one day old:
MYSQL
Sets the connection then creates a new database.
[!NOTE] The sqlite driver to doesn't need a connection because it uses the
Illuminate\Support\Storage
helper under the hood.
Soft deletes the database and moves it to deleted_2023_3_2_7_04_38_my_new_database
No mtime for mysql, simply compares $daysOld
against the formated time segment in the deleted name 2023_3_2_7_04_38_
.
This is done by using Carbon::createFromFormat('Y_m_H_h_i_s_')
.
Creating Managers
Out of the box this package includes managers for sqlite and mysql. You can create your own managers and add them to the managers array in the database-manager config.
Feel free to submit a PR
for any additional custom managers that use standard laravel drivers, such as postgres.
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
- Parts of this package are inspired by the
DatabaseManager
classes in Tenancy for Laravel - Spatie's CONTRIBUTING.md
- This package was generated using spatie/package-skeleton-laravel
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-database-manager with dependencies
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
spatie/laravel-package-tools Version ^1.16.2