protected function onPrepare($argv = null) { $this->thisApp = App::getApp(); $root = $this->getNewAppDir(); if (is_dir($root)) { throw new \Exception("Directory {$root} is existing!"); } $kephpEntry = relative_path($root, $this->thisApp->kephp()); list($path, $phar) = split_phar($kephpEntry); if ($phar !== false) { $kephpEntry = "'phar://' . __DIR__ . '{$path}/{$phar}{$this->entryFile}'"; } else { $kephpEntry = "__DIR__ . '{$path}{$this->entryFile}'"; } $this->context['kephpLibEntry'] = $kephpEntry; if (empty($this->appNamespace)) { $this->appNamespace = path2class($this->name); } else { if (!preg_match('#^[a-z0-9_]+$#i', $this->appNamespace)) { throw new \Exception("App namespace only can use char in a-z0-9_."); } } $this->context['appNamespace'] = trim($this->appNamespace, KE_PATH_NOISE); }
public final function __construct(Http $http = null) { // 绑定当前的默认的上下文环境实例 if (!isset(self::$web)) { self::$web = $this; } $this->app = App::getApp(); if (!$this->app->isInit()) { $this->app->init(); } $this->ob = OutputBuffer::getInstance()->start('webStart'); $this->mime = $this->app->getMime(); $this->http = $http ?? Http::current(); $this->component = (new Component())->setDirs(['appView' => [$this->app->appNs('View'), 100, Component::VIEW], 'appComponent' => [$this->app->appNs('Component'), 100], 'kephpComponent' => [$this->app->kephp('Ke/Component'), 1000]]); $this->prepare(); $this->onConstruct(); }