Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
配置文件房子入口文件加载
Browse files Browse the repository at this point in the history
  • Loading branch information
suyar committed May 1, 2017
1 parent 2063547 commit 5bb18ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
16 changes: 14 additions & 2 deletions kernel/Lying.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ class Lying
*/
public static $maker;

/**
* 启动框架
* @param $config 配置数组
*/
public static function run($config)
{
if (self::$maker === null) {
self::boot($config);
self::$maker->dispatch()->run();
}
}

/**
* 初始化启动参数
* @param array $config 全局配置数组
*/
public static function boot($config)
private static function boot($config)
{
self::$config = $config;

Expand Down Expand Up @@ -60,7 +72,7 @@ public static function config($key, $default = null)
* 自动加载
* @param string $className 完整类名
*/
public static function autoload($className)
private static function autoload($className)
{
if (($classFile = self::classMapLoader($className)) ||
($classFile = self::psr4Loader($className)) ||
Expand Down
6 changes: 3 additions & 3 deletions kernel/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function url($path, $params = [], $normal = false)
*/
function lock($name, $type)
{
if (is_dir(DIR_ROOT . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'lock') ||
mkdir(DIR_ROOT . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'lock', 0777, true)) {
if (false !== $fp = fopen(DIR_ROOT . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'lock' . DIRECTORY_SEPARATOR . $name, 'w')) {
if (is_dir(DIR_ROOT . '/runtime/' . 'lock') ||
mkdir(DIR_ROOT . '/runtime/' . 'lock', 0777, true)) {
if (false !== $fp = fopen(DIR_ROOT . "/runtime//lock/$name", 'w')) {
if (flock($fp, $type)) {
return $fp;
} else {
Expand Down
2 changes: 0 additions & 2 deletions kernel/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@

require __DIR__ . '/Lying.php';

Lying::boot(require DIR_CONFIG . '/web.php');

require __DIR__ . '/function.php';
2 changes: 1 addition & 1 deletion web/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
version_compare(PHP_VERSION, '5.5.0', '>=') || die('Lying require 5.5.0 or higher PHP version :)');
require __DIR__ . '/../kernel/init.php';
Lying::$maker->dispatch()->run();
Lying::run(require DIR_CONFIG . '/web.php');

0 comments on commit 5bb18ce

Please sign in to comment.