生成sitemap
This commit is contained in:
parent
eb3754816f
commit
9f80c71d42
@ -20,7 +20,9 @@ export default defineConfig({
|
|||||||
// 默认禁用图片懒加载
|
// 默认禁用图片懒加载
|
||||||
lazyLoading: true
|
lazyLoading: true
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
sitemap: {
|
||||||
|
hostname: 'https://www.xiaokeaii.top'
|
||||||
},
|
},
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
outlineTitle: '页面导航',
|
outlineTitle: '页面导航',
|
||||||
|
@ -9,8 +9,8 @@ export default [
|
|||||||
items: [
|
items: [
|
||||||
{ text: '阅读版本', link: hyperf + '阅读版本' },
|
{ text: '阅读版本', link: hyperf + '阅读版本' },
|
||||||
{ text: '入口文件', link: hyperf + '入口文件' },
|
{ text: '入口文件', link: hyperf + '入口文件' },
|
||||||
{ text: '初始化依赖注入 (DI) 容器', link: hyperf + '初始化依赖注入 (DI) 容器' },
|
{ text: '初始化依赖注入 (DI) 容器', link: hyperf + 'DI' },
|
||||||
{ text: 'container', link: hyperf + 'container' },
|
{ text: '初始化容器类', link: hyperf + 'container' },
|
||||||
{ text: '启动服务', link: hyperf + '启动服务' },
|
{ text: '启动服务', link: hyperf + '启动服务' },
|
||||||
{ text: '请求', link: hyperf + '请求' },
|
{ text: '请求', link: hyperf + '请求' },
|
||||||
{ text: '路由寻址', link: hyperf + '路由寻址' },
|
{ text: '路由寻址', link: hyperf + '路由寻址' },
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
title: 初始化依赖注入 (DI) 容器
|
title: 初始化依赖注入 (DI) 容器
|
||||||
---
|
---
|
||||||
## 初始化依赖注入 (DI) 容器
|
# 初始化依赖注入 (DI) 容器
|
||||||
|
|
||||||
```php
|
```php
|
||||||
(function () {
|
(function () {
|
||||||
|
|
@ -1,24 +1,34 @@
|
|||||||
---
|
---
|
||||||
title: 初始化容器类
|
title: 初始化容器类
|
||||||
---
|
---
|
||||||
|
# 初始化容器类
|
||||||
本节分析容器类,
|
本节分析容器类的实例化过程,
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$container = require BASE_PATH . '/config/container.php';
|
(function () {
|
||||||
|
Hyperf\Di\ClassLoader::init();
|
||||||
|
/** @var Psr\Container\ContainerInterface $container */
|
||||||
|
$container = require BASE_PATH . '/config/container.php'; // [!code focus]
|
||||||
|
|
||||||
|
$application = $container->get(Hyperf\Contract\ApplicationInterface::class);
|
||||||
|
$application->run();
|
||||||
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
这是容器类初始化的代码,
|
这是容器类初始化的代码,
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use Hyperf\Context\ApplicationContext;
|
use Hyperf\Context\ApplicationContext;
|
||||||
use Hyperf\Di\Container;
|
use Hyperf\Di\Container;
|
||||||
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
||||||
|
|
||||||
$container = new Container((new DefinitionSourceFactory())());
|
$container = new Container((new DefinitionSourceFactory())()); // [!code warning]
|
||||||
|
|
||||||
return ApplicationContext::setContainer($container);
|
return ApplicationContext::setContainer($container);
|
||||||
|
|
||||||
```
|
```
|
||||||
> 首先,可以看出,先是`new`了 一个`DefinitionSourceFactory`类,然后使用方法的调用方式调用类,会触发该类的`__invoke`方法,最后返回的内容作为`Container`类的构造函数的参数,然后返回容器类。
|
|
||||||
|
首先,可以看出,先是实例化了`DefinitionSourceFactory`类,然后使用方法的调用方式调用类,会触发该类的`__invoke`方法,最后返回的内容作为`Container`类的构造函数的参数,然后返回实例化后的容器类。
|
||||||
|
|
||||||
### DefinitionSourceFactory类
|
### DefinitionSourceFactory类
|
||||||
先看该类做了那些工作,
|
先看该类做了那些工作,
|
||||||
|
Loading…
Reference in New Issue
Block a user