agashe / sigmaphp-db
PHP Database Tools
Requires
- doctrine/inflector: 2.*
Requires (Dev)
- phpunit/phpunit: ^9.5
README
SigmaPHP-DB is a collection of PHP Database Tools. That support primarily MySQL RDBMS (Other RDBMS support will be added in future). Including migrations with rollback , seeding , query builder , ORM and much more , all these features can be used through an elegant CLI script in your terminal.
Installation
composer require agashe/sigmaphp-db
Configurations
After installation , you should create a new config file , to include your database connection parameters , and also edit other options like migrations / seeders paths.
To generate new config file , run the following command :
php ./vendor/bin/sigma-db create:config
A new config file with name database.php wil be created in the root of your project's directory.
You can simply change the name and the location of the config file , but this will require you , to pass the config file path , when use the CLI script :
php ./vendor/bin/sigma-db migrate --config=/path/to/my-config.php
Documentation
CLI Usage
In the table below , you can find all available commands :
And here few examples on how to use the commands:
php ./vendor/bin/sigma-db create:migration UsersTable
// will create UsersTableMigration.php file into /path/to/migrations
php ./vendor/bin/sigma-db create:seed UsersRolesSeeder
// run seeder UsersRolesSeeder.php
php ./vendor/bin/sigma-db create:rollback 2023-1-20
// rollback all migrations up to 2023-1-20 , the migrations running dates all saved into the migrations logs table (default name is db_logs). And of course you can change it in the config file
php ./vendor/bin/sigma-db drop
// to drop all tables
php ./vendor/bin/sigma-db fresh --config=/path/to/db-testing-config.php
// to drop all tables then migrate and seed , and in this example we assume that you have put the config in your path of choice
License
(SigmaPHP-DB) released under the terms of the MIT license.