示例#1
0
 * @link      http://buildwithcraft.com
 */
/**
 * @param $dbHostname
 * @return string
 */
function normalizeDbHostname($dbHostname)
{
    // MacOS command line db connections apparently want this in numeric format.
    if (strcasecmp($dbHostname, 'localhost') == 0) {
        $dbHostname = '127.0.0.1';
    }
    return $dbHostname;
}
/**
 * Returns the correct connection string depending on whether a unixSocket is specific or not in the db config.
 *
 * @param $dbConfig
 * @return string
 */
function processConnectionString($dbConfig)
{
    if (!empty($dbConfig['unixSocket'])) {
        return strtolower('mysql:unix_socket=' . $dbConfig['unixSocket'] . ';dbname=' . $dbConfig['database'] . ';');
    } else {
        return strtolower('mysql:host=' . normalizeDbHostname($dbConfig['server']) . ';dbname=' . $dbConfig['database'] . ';port=' . $dbConfig['port'] . ';');
    }
}
$common = (require CRAFT_APP_PATH . 'etc/config/common.php');
return CMap::mergeArray($common, array('basePath' => dirname(__FILE__) . '/../../', 'import' => array('application.*', 'application.migrations.*'), 'componentAliases' => array('app.*', 'app.enums.*', 'app.etc.components.*', 'app.etc.console.*', 'app.etc.console.commands.*', 'app.etc.dates.*', 'app.etc.db.*', 'app.etc.db.schemas.*', 'app.etc.io.*', 'app.etc.logging.*', 'app.etc.updates.*', 'app.helpers.*', 'app.migrations.*', 'app.services.*', 'app.validators.*'), 'components' => array('db' => array('connectionString' => processConnectionString($dbConfig), 'emulatePrepare' => true, 'username' => $dbConfig['user'], 'password' => $dbConfig['password'], 'charset' => $dbConfig['charset'], 'tablePrefix' => $tablePrefix, 'driverMap' => array('mysql' => 'Craft\\MysqlSchema'), 'class' => 'Craft\\DbConnection'), 'migrations' => array('class' => 'Craft\\MigrationsService')), 'commandPath' => Craft\Craft::getPathOfAlias('system.cli.commands.*')));
示例#2
0
    defined('CRAFT_CONFIG_PATH') || define('CRAFT_CONFIG_PATH', $frontConfigPath);
} else {
    defined('CRAFT_CONFIG_PATH') || define('CRAFT_CONFIG_PATH', CRAFT_BASE_PATH . 'config/');
}
defined('CRAFT_PLUGINS_PATH') || define('CRAFT_PLUGINS_PATH', CRAFT_BASE_PATH . 'plugins/');
defined('CRAFT_STORAGE_PATH') || define('CRAFT_STORAGE_PATH', CRAFT_BASE_PATH . 'storage/');
defined('CRAFT_TEMPLATES_PATH') || define('CRAFT_TEMPLATES_PATH', CRAFT_BASE_PATH . 'templates/');
defined('CRAFT_TRANSLATIONS_PATH') || define('CRAFT_TRANSLATIONS_PATH', CRAFT_BASE_PATH . 'translations/');
defined('CRAFT_ENVIRONMENT') || define('CRAFT_ENVIRONMENT', 'console');
/**
 * Yii command line script file configured for Craft.
 */
// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require_once dirname(__FILE__) . '/../../framework/yii.php';
require_once CRAFT_APP_PATH . 'Craft.php';
require_once CRAFT_APP_PATH . 'Info.php';
// Guzzle makes use of these PHP constants, but they aren't actually defined in some compilations of PHP.
// See http://it.blog.adclick.pt/php/fixing-php-notice-use-of-undefined-constant-curlopt_timeout_ms-assumed-curlopt_timeout_ms/
defined('CURLOPT_TIMEOUT_MS') || define('CURLOPT_TIMEOUT_MS', 155);
defined('CURLOPT_CONNECTTIMEOUT_MS') || define('CURLOPT_CONNECTTIMEOUT_MS', 156);
// Load up Composer's files
require CRAFT_APP_PATH . 'vendor/autoload.php';
// Disable the PHP include path
Yii::$enableIncludePath = false;
require_once dirname(__FILE__) . '/ConsoleApp.php';
Yii::setPathOfAlias('app', CRAFT_APP_PATH);
Yii::setPathOfAlias('plugins', CRAFT_PLUGINS_PATH);
$app = Yii::createApplication('Craft\\ConsoleApp', $configPath);
$app->commandRunner->addCommands(Craft\Craft::getPathOfAlias('application.consolecommands.*'));
$app->run();