Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized cacheable for DefinitionSource. #463

Merged
merged 15 commits into from Sep 2, 2019

Conversation

limingxinleo
Copy link
Member

@limingxinleo limingxinleo commented Aug 27, 2019

简化 container.php 配置如下

<?php
/**
 * Initial a dependency injection container that implemented PSR-11 and return the container.
 */

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Utils\ApplicationContext;

$container = new Container((new DefinitionSourceFactory(true))());

if (! $container instanceof \Psr\Container\ContainerInterface) {
    throw new RuntimeException('The dependency injection container is invalid.');
}
return ApplicationContext::setContainer($container);

另外,ConfigProvider 中增加 scan.collectors 配置,可以使用收集器缓存

<?php
class ConfigProvider
{
    public function __invoke(): array
    {
        return [
            'scan' => [
                'collectors' => [
                    AnnotationCollector::class,
                    AspectCollector::class,
                ],
            ],
        ];
    }
}

@huangzhhui huangzhhui added this to In progress in Version 2.0 via automation Aug 27, 2019
Version 2.0 automation moved this from In progress to Reviewer approved Sep 1, 2019
Copy link
Member

@huangzhhui huangzhhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看着没什么问题,但我还没测试,感觉可以先 merge 进来,在后面的开发中再检验这里

@limingxinleo limingxinleo merged commit c9f8eeb into hyperf:master Sep 2, 2019
Version 2.0 automation moved this from Reviewer approved to Done Sep 2, 2019
@limingxinleo limingxinleo deleted the 1.1-collector branch September 2, 2019 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Version 2.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants