philwc/version-db
Composer 安装命令:
composer require philwc/version-db
包简介
Easy database versioning :)
关键字:
README 文档
README
#VersionDB
##To Install:
- Add to your composer.json:
"require": {
"philwc/version-db": "dev-master"
}
- Run
composer.phar update
- Add a settings.yml file:
parameters:
database:
user: <DBUSER>
password: <DBPASS>
host: <DBHOST>
name: <DBNAME>
changelogtable: changelog
file:
sqlDir: <LOCATION OF SQL FILES>
- Create a new file in the project root called console, with the following contents:
#!/usr/bin/env php <?php require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/philwc/version-db/console';
##To Use:
- Add A Revision:
php console add
You will be prompted to fill in the required fields
- Upgrade Database:
php console upgrade
This will read the SQL Dir (From settings.yml) and apply the update SQL scripts in date order
- Downgrade Database:
php console downgrade
This will read the changelog table and allow you to select where to downgrade to. It will then apply the downgrade SQL scripts in date descending order until it hits the record specified.
- Web Front End:
There is an example file (index.php) for how to use the front end. The fields may be rendered by the class, using
$change = new \philwc\Web\AddChange(); $change->getHtml($action);
or by rendering manually, i.e.
$change = new \philwc\Web\AddChange(); $html = '<form id="vdbAdd" method="POST">'; foreach ($change->getFields() as $field) { //Split the fields names into a nice title format $a = preg_split('/(?<=[a-z])(?=[A-Z])/x', $field); $fieldTitle = ucwords(implode(' ', $a)); $html .= '<label class="input-group" for="' . $field . '">' . $fieldTitle . ': <input class="visibleInput" type="text" name="' . $field . '" id="' . $field . '"/></label>'; } $html .= '<input name="submit" type="submit"></form>'; echo $html;
统计信息
- 总下载量: 256
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-10-11