承接 turanct/bdsm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

turanct/bdsm

最新稳定版本:0.0.1

Composer 安装命令:

composer require turanct/bdsm

包简介

BDSM Does Simple Migrations

README 文档

README

Travis CI

A really simple migrations library. It is currently not meant to be used in production but nobody's going to stop you if you really want to. Use at your own risk.

Usage

Installing

Installing it is easy, just require turanct/bdsm as a development dependency in your composer.json file, and configure a bin-dir. The bdsm executable will be available in your bin directory when you've run composer install.

{
    "require-dev": {
        "turanct/bdsm": "dev-master"
    },
    "config": {
        "bin-dir": "bin"
    }
}

Bootstrapping

The bdsm executable expects a .bdsm.php file in the working directory of your project. In this file you can do all necessary bootstrapping. It just needs to return an array with these elements:

  1. The directory where we can find migrations
  2. The file in which we can log which migrations we ran
  3. A database adapter, implementing the really simple Bdsm\Database interface
<?php

use Bdsm\Database;

final class MyDatabaseAdapter implements Database
{
    public function query($query)
    {
        var_dump($query);
    }
}

return array(
    __DIR__ . '/migrations',
    __DIR__ . '/.bdsm.log.json',
    new MyDatabaseAdapter(),
);

In this case, we provided a directory migrations in which the migrations will live, and a log file .bdsm.log.json to which the system can log. The database adapter in this example will not actually connect to a database, but it will print out every query issued.

First migration

We're ready to create our first migration right now! Run the bdsm command with the create parameter.

$ bin/bdsm create
Migration "Migration1441375998" created...

You can also pass a custom migration name as a parameter. A new migration will be created in our migrations directory with these contents:

<?php

use Bdsm\Migration;
use Bdsm\Database;

final class Migration1441375998 implements Migration
{
    public function up(Database $database)
    {
    }

    public function down(Database $database)
    {
    }
}

We can now simply script the up and down actions for our migration, and then check it's status. It should be red.

$ bin/bdsm status
✘ Migration1441375998

Running it is as simple as bdsm up Migration1441375998. Note that you can run all migrations at once using bdsm up without arguments.

$ bin/bdsm up Migration1441375998
Do you want to migrate UP migration Migration1441375998? (Y/n)

Migrated...

Another look at the migration status shows us that we succeeded!

$ bin/bdsm status
✔︎ Migration1441375998

Migrating down is exactly the same procedure, but with down instead of up commands.

Tests

BDSM has unit tests, located in the tests directory. These tests are written using phpunit. To run them, make sure you did a composer install and run phpunit.

$ sbin/phpunit

Contributing

Feel free to fork and send pull requests!

License

This library is MIT licensed. See also LICENSE.md

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固