该包已被废弃,不再维护。未建议替换包。
此包最新版本(v0.1.5)没有提供许可信息。

Web应用程序安装程序

v0.1.5 2016-06-08 11:26 UTC

This package is auto-updated.

Last update: 2022-02-22 01:53:49 UTC


README

Web应用程序安装程序

使用方法

在您的入口文件(例如 index.php)中添加以下语句以使此工作。

<?php

// index.php
// mark file and line to clean
Wai::mark(__FILE__, $lineStart = 6, $lineEnd = 62);

// configuration
$config = [
    // current version
    'version'      => '0.1.0',
    // used for saving installed version and schema, ensure this directory is writable
    'workingDir'   => 'tmp/',
    // schema directory that contains every schema that need to be installed
    // filename should be prefixed by ordered number
    'schemaDir'    => 'app/schema/',
    // argument for constructing PDO class
    'database'     => [
        // dsn, string, without database name
        'dsn'      => 'mysql:host=127.0.0.1',
        // username, string
        'username' => 'root',
        // password, string
        'password' => null,
        // options, array
        'options'  => [],
        // database name
        'dbname'   => 'test_wai',
        // drop db first
        'dropdb'   => false,
    ],
];
Wai::setup($config);

// check if current version is same as installed version
if (Wai::isNotInstalled()) {

	// not installed, install it
	// you can pass array of callback that will be execute
	// before and after database procedure called
    $dir = __DIR__;
    $callbacksBefore = [
        function() use ($dir) {
            chmod($dir.'/tmp', 0777);
        },
        function() {
            // other statements to do
        },
    ];
    $callbacksAfter = [
        function() {
            // other statements to do
        },
    ];
    Wai::handleInstallation($callbacksBefore, $callbacksAfter);
}

// catch result
// $result = Wai::result();

// or write result and exit
Wai::hold();