agashe/sigmaphp-db 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agashe/sigmaphp-db

最新稳定版本:0.1.15

Composer 安装命令:

composer require agashe/sigmaphp-db

包简介

PHP Database Tools

README 文档

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 :

Command Description
create:config {path} Create new config file, if no path was provided , a default config file (database.php) will be created in the root of the project's folder.
create:migration {migration name} Create new migration file. It's recommended for the migration file to follow class naming rules , like using only nouns and PascalCase .. etc. Also no need to add .php extension , "Migration.php". will be appended automatically to the file name.
create:model {model name} Create new model class. In addition this command will generate a migration file for creating the corresponding table.
create:seeder {seeder name} Create new seeder file. Please note that , the same rules for naming the migration file is also applied to the seeder.
drop Drop all tables in the database. A confirmation message will ask you to confirm before executing this command.
fresh Drop all tables in the database. then will run all migrations and seed the database. (will ask for confirmation)
help Print a list by all available commands.
migrate {migration name} Run all migrations files. Optionally you can pass migration file name , to run specific migration.
rollback {date} Rollback latest migration. or choose specific date to rollback to.
seed {seeder name} Run seeders. or run specific seeder.
version Print the current version of SigmaPHP-DB Package.
truncate Delete the data in all tables. (will ask for confirmation)

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 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.

统计信息

  • 总下载量: 544
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固