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 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,
                ],
            ],
        ];
    }
}
@limingxinleo limingxinleo requested review from huangzhhui and daydaygo Aug 27, 2019
@huangzhhui huangzhhui added this to In progress in Version 1.2 via automation Aug 27, 2019
Version 1.2 automation moved this from In progress to Reviewer approved Sep 1, 2019
Copy link
Member

huangzhhui left a comment

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

@limingxinleo limingxinleo merged commit c9f8eeb into hyperf:master Sep 2, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Version 1.2 automation moved this from Reviewer approved to Done Sep 2, 2019
@limingxinleo limingxinleo deleted the limingxinleo:1.1-collector branch Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Version 1.2
  
Done
3 participants
You can’t perform that action at this time.