-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
54 lines (51 loc) · 1.36 KB
/
bootstrap.php
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
<?php
require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
$config = [
'id' => 'micro-app',
// the basePath of the application will be the `micro-app` directory
'basePath' => __DIR__,
// this is where the application will find all controllers
// 'controllerNamespace' => 'app\controllers',
'bootstrap' => [
'log',
],
// set an alias to enable autoloading of classes from the 'app' namespace
'aliases' => [
'@app' => __DIR__,
],
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yourdatabasename',
'username' => 'yourusername',
'password' => 'yourpassword',
'charset' => 'utf8',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
// 'logFile' => '@app/app.log', //if you don't want to use default (see Yii documentation)
'levels' => ['error', 'warning'],
'maxFileSize' => 1024, // 1 Mb
],
],
],
],
];
if (PHP_SAPI === 'cli') {
// when running a console application
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
} else {
// when running through a webserver
(new yii\web\Application($config));
}
class Customer extends \yii\db\ActiveRecord {
public static function tableName() {
return 'main_customers';
}
}