Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
forked from 后盾人/v2015
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
App.php 4.44 KB
Copy Edit Raw Blame History
后盾人 authored 2017年05月02日 15:00 +08:00 . no message
<?php
// .-------------------------------------------------------------------
// | Software: [HDPHP framework]
// | Site: www.hdphp.com
// |-------------------------------------------------------------------
// | Author: 向军 <2300071698@qq.com>
// | WeChat: houdunwangxj
// | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
// '-------------------------------------------------------------------
namespace hdphp\kernel;
use ReflectionClass;
use Hdphp\Kernel\ServiceProviders;
class App extends Container {
//应用已启动
protected $booted = FALSE;
//系统服务
protected $servers = [ ];
//外观别名
protected $facades = [ ];
//延迟加载服务提供者
protected $deferProviders = [ ];
//已加载服务提供者
protected $serviceProviders = [ ];
// 构造函数
public function run() {
$this->servers = require ROOT_PATH . '/system/config/service.php';
//自动加载系统服务
Loader::register( [ $this, 'autoload' ] );
//绑定核心服务提供者
$this->bindServiceProvider();
//添加初始实例
$this->instance( 'App', $this );
//设置外观类APP属性
ServiceFacade::setFacadeApplication( $this );
Error::bootstrap();
//导入类库别名
Loader::addMap( Config::get( 'app.alias' ) );
//自动加载文件
Loader::autoloadFile();
//启动服务
$this->boot();
//应用目录
define( 'APP_PATH', ROOT_PATH . '/' . C( 'app.path' ) );
define( 'APP', basename( APP_PATH ) );
//时区设置
date_default_timezone_set( Config::get( 'app.timezone' ) );
//CLI模式
$this->cli();
//导入钓子
Hook::import( Config::get( 'hook' ) );
//应用开始钩子
Hook::listen( 'app_begin' );
//解析路由
Route::dispatch();
//记录日志
Log::save();
//应用结束钩子
Hook::listen( 'app_end' );
}
// 执行请求
public function cli() {
//命令模式
if ( $_SERVER['SCRIPT_NAME'] == 'hd' ) {
require_once HDPHP_PATH . '/cli/Cli.php';
\hdphp\cli\Cli::run();
exit;
}
}
//类文件自动加载
public function autoload( $class ) {
//通过外观类加载系统服务
$file = str_replace( '\\', '/', $class );
$facade = basename( $file );
if ( isset( $this->servers['facades'][ $facade ] ) ) {
//加载facade类
return class_alias( $this->servers['facades'][ $facade ], $class );
}
}
// 系统启动
public function boot() {
if ( $this->booted ) {
return;
}
foreach ( $this->serviceProviders as $p ) {
$this->bootProvider( $p );
}
$this->booted = TRUE;
}
// 服务加载处理
public function bindServiceProvider() {
foreach ( $this->servers['providers'] as $provider ) {
$reflectionClass = new ReflectionClass( $provider );
$properties = $reflectionClass->getDefaultProperties();
//获取服务延迟属性
if ( isset( $properties['defer'] ) && $properties['defer'] ) {
$alias = substr( $reflectionClass->getShortName(), 0, - 8 );
//延迟加载服务
$this->deferProviders[ $alias ] = $provider;
} else {
//立即加载服务
$this->register( new $provider( $this ) );
}
}
}
/**
* 获取服务对象
*
* @param 服务名 $name 服务名
* @param bool $force 是否单例
*
* @return Object
*/
public function make( $name, $force = FALSE ) {
if ( isset( $this->deferProviders[ $name ] ) ) {
$this->register( new $this->deferProviders[$name]( $this ) );
unset( $this->deferProviders[ $name ] );
}
return parent::make( $name, $force );
}
/**
* 注册服务
*
* @param $provider 服务名
*
* @return object
*/
public function register( $provider ) {
//服务对象已经注册过时直接返回
if ( $registered = $this->getProvider( $provider ) ) {
return $registered;
}
if ( is_string( $provider ) ) {
$provider = new $provider( $this );
}
$provider->register( $this );
//记录服务
$this->serviceProviders[] = $provider;
if ( $this->booted ) {
$this->bootProvider( $provider );
}
}
/**
* 运行服务提供者的boot方法
*
* @param $provider
*/
protected function bootProvider( $provider ) {
if ( method_exists( $provider, 'boot' ) ) {
$provider->boot();
}
}
/**
* 获取已经注册的服务
*
* @param $provider 服务名
*
* @return mixed
*/
protected function getProvider( $provider ) {
$class = is_object( $provider ) ? get_class( $provider ) : $provider;
foreach ( $this->serviceProviders as $value ) {
if ( $value instanceof $class ) {
return $value;
}
}
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

后盾人视频教程代码,收到 Star 我们会更有动力。
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/itcode-itcode/video.git
git@gitee.com:itcode-itcode/video.git
itcode-itcode
video
video
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /