Test Failed
Push — master ( 37d3cb...34a83f )
by kill
03:43
created

core/App.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Created by rozbo at 2017/3/18 下午8:52
4
 */
5
6
namespace puck;
7
8
9
use Dotenv\Dotenv;
10
use Whoops\Run;
11
12
class App extends Container {
13
14
    /**
15
     * 应用的根目录.
16
     *
17
     * @var string
18
     */
19
    protected $basePath;
20
    public function __construct($basePath) {
21
        $this->basePath=$basePath;
22
        $this->initEnv();
23
        $this->initContainer();
24
    }
25
26
    private function initEnv(){
27
        $dotEnv = new Dotenv($this->basePath);
28
        $dotEnv->load();
29
        date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Shanghai'));
30
        define('IS_CLI', php_sapi_name() == 'cli');
31
        if (env('DEBUG',false)) {
32
            error_reporting(E_ALL);
33
            @ini_set('display_errors', 'On');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
34
            //@ob_start();
35
            $whoops=new Run;
36
            $handle=IS_CLI ? "PlainTextHandler" : "PrettyPageHandler";
37
            $handle="\\Whoops\\Handler\\".$handle;
38
            $whoops->pushHandler(new $handle);
39
            $whoops->register();
40
        }
41
42
    }
43
    /**
44
     * 初始化容器
45
     */
46
    private function initContainer() {
47
        static::setInstance($this);
48
        $this->instance('app',$this);
49
        $this->bind('pinyin','\puck\helpers\PinYin');
50
    }
51
52
}