2amigos / yiinitializr
此包已被废弃且不再维护。未建议替代包。
Yii Web编程框架应用程序初始化库。
1.0.1
2013-04-18 05:47 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2023-08-16 02:18:26 UTC
README
已弃用。在2amigos,我们不再支持Yii 1。我们强烈建议您尽快采用Yii 2。
Yiinitializr
库,可以帮助您轻松加速应用程序安装,并从其引导文件以更干净的方式运行Yii应用程序,这比框架当前提出的方式更有效。例如
// if installed via composer
require('./../../common/lib/vendor/autoload.php');
Yiinitializr\Helpers\Initializer::create('./../', 'frontend', array(
__DIR__ .'/../../common/config/main.php',
__DIR__ .'/../../common/config/env.php',
__DIR__ .'/../../common/config/local.php'
))->run();
##如何使用它 如果您打算使用Yiinitializr来利用Yiinitializr\Helpers\Initializr
,您可以通过composer
轻松安装它,但如果您打算在您的应用程序结构中使用它,以便根据您的自定义需求配置应用程序,那么推荐的使用方法是您下载其源文件并将它们放置在顶层文件夹中。
###配置设置 与Yii一样,如果您希望使用composer
处理项目结构设置,您需要经过一些配置设置。不要担心,这不会太难,以下是一个示例配置文件
\\ where am i?
$dirname = dirname(__FILE__);
\\ where is the application folder?
$app = $dirname . '/../../..';
\\ where is the root?
$root = $app . '/..';
return array(
// yii configurations
'yii' => array(
// where is the path of the yii framework?
// On this example we have installed yii with composer
// and as it is used after composer installation, we
// can safely point to the vendor folder.
'path' => $app . '/lib/vendor/yiisoft/yii/framework'
),
// yiinitializr specific settings
'yiinitializr' => array(
// config folders
'config' => array(
// we just need the console settings
// On this example, and due that I used environments
// i created a custom console.php app for
// Yiinitializr\Composer\Callbak class (see below example)
'console' => $dirname . '/console.php'
),
// application structure settings
'app' => array(
// where is the root?
'root' => $root,
// directories setup
'directories' => array(
// where are the different configuration files settings?
'config' => array(
// 'key' is the configuration name (see above init example)
'main' => $app . '/config',
'console' => $app . '/config',
'test' => $app . '/config'
),
// where are my runtime folders?
'runtime' => array(
// heads up! only the folder location as "/config" will be
// appended
$app
),
'assets' => array(
// where to write the "assets folders"?
$root . '/www'
)
),
'files' => array(
// files to merge the main configuration file with
// initializr will merge it automatically
'config' => array(
'main' => array('env', 'local'),
'console' => array('env', 'local'),
)
)
),
)
);
以下是在与环境一起工作时自定义console.php
设置文件的示例。如您在上一段代码中看到的,此示例文件位于同一Yiinitializr\config
文件夹中
require_once dirname(__FILE__) . '/../Helpers/Initializer.php';
require_once dirname(__FILE__) . '/../Helpers/ArrayX.php';
return Yiinitializr\Helpers\ArrayX::merge(
Yiinitializr\Helpers\Initializer::config('console', array('common', 'env', 'local')),
array(
'params' => array(
// here is where the composer magic start.
// Thanks! mr Tobias a.k.a Phundament man!
'composer.callbacks' => array(
'post-update' => array('yiic', 'migrate'),
'post-install' => array('yiic', 'migrate'),
)
),
)
);
####示例
###要求 它与composer
一起工作以安装样板文件,但Yiinitializr的最小要求是您已安装composer
或在应用程序根目录中有一个composer.phar
文件,以便运行** PHP 5.3+**
###资源
网页开发从未如此有趣
www.2amigos.us