-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
82 lines (67 loc) · 1.71 KB
/
Copy pathbootstrap.php
File metadata and controls
82 lines (67 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Created by PhpStorm.
* User: yiqing
* Date: 2015/10/6
* Time: 19:42
*/
define('DS', DIRECTORY_SEPARATOR);
/**
* return the vendor dir
*
* @return string
*/
function VendorDir()
{
$rootBaseName = 'php-space';
$phpSpaceRootDir = substr(__DIR__, 0, strpos(__DIR__, $rootBaseName)) . $rootBaseName;
// die($phpSpaceRootDir) ;
$vendorDir = $phpSpaceRootDir . DS . 'vendor';
return $vendorDir;
}
/**
*
*/
function autoloadVendor()
{
$vendorDir = VendorDir();
require $vendorDir . '/autoload.php';
}
// using composer
autoloadVendor();
/**
* using yii : http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html
*
*
* @param array $yiiConfig
*/
function UsingYii($yiiConfig = [])
{
// require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
require(VendorDir() . '/yiisoft/yii2/Yii.php');
// $yiiConfig = require(__DIR__ . '/../config/yii/web.php');
$defaultConfig =
[
'id' => 'my-yii-app',
'language' => 'zh-CN',
'basePath' => dirname(__DIR__),
'bootstrap' => [
'log',
],
'modules' => [
],
'components' => [
'request' => [
'cookieValidationKey' => 'anyRandomString',//getenv('COOKIE_VALIDATION_KEY'),
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
],
'params' => [
],
];
// merger the config with default one
$yiiConfig = \yii\helpers\ArrayHelper::merge($defaultConfig, $yiiConfig);
new \yii\web\Application($yiiConfig); // Do NOT call run() here
}