Use Hyperf\Context\ApplicationContext instead of Hyperf\Utils\ApplicationContext. (#5621)

This commit is contained in:
李铭昕 2023-04-11 15:57:32 +08:00 committed by GitHub
parent 7d97774f99
commit c422dad528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
251 changed files with 298 additions and 296 deletions

View File

@ -6,6 +6,7 @@
- [#5617](https://github.com/hyperf/hyperf/pull/5617) Removed the requirement `hyperf/guzzle` from `hyperf/consul`. - [#5617](https://github.com/hyperf/hyperf/pull/5617) Removed the requirement `hyperf/guzzle` from `hyperf/consul`.
- [#5618](https://github.com/hyperf/hyperf/pull/5618) Support to set the default router for swagger. - [#5618](https://github.com/hyperf/hyperf/pull/5618) Support to set the default router for swagger.
- [#5619](https://github.com/hyperf/hyperf/pull/5619) [#5620](https://github.com/hyperf/hyperf/pull/5620) Split `hyperf/coroutine` from `hyperf/utils`. - [#5619](https://github.com/hyperf/hyperf/pull/5619) [#5620](https://github.com/hyperf/hyperf/pull/5620) Split `hyperf/coroutine` from `hyperf/utils`.
- [#5621](https://github.com/hyperf/hyperf/pull/5621) Use `Hyperf\Context\ApplicationContext` instead of `Hyperf\Utils\ApplicationContext`.
# v3.0.15 - 2023-04-07 # v3.0.15 - 2023-04-07

View File

@ -77,7 +77,7 @@ Get the Producer instance through container, and you can deliver the message. It
<?php <?php
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use App\Amqp\Producers\DemoProducer; use App\Amqp\Producers\DemoProducer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$message = new DemoProducer(1); $message = new DemoProducer(1);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);

View File

@ -2619,7 +2619,7 @@ config/container.php
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = new Container((new DefinitionSourceFactory(true))()); $container = new Container((new DefinitionSourceFactory(true))());

View File

@ -61,7 +61,7 @@ The specific interface can be viewed `Hyperf\DB\ConnectionInterface`。
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\DB\DB; use Hyperf\DB\DB;
$db = ApplicationContext::getContainer()->get(DB::class); $db = ApplicationContext::getContainer()->get(DB::class);

View File

@ -413,10 +413,10 @@ class IndexController
} }
``` ```
In some more extreme dynamic situations, or when it is not under the management of `Container`, you can also use `\Hyperf\Utils\ApplicationContext::getContaienr()` method to obtain the `Container` object. In some more extreme dynamic situations, or when it is not under the management of `Container`, you can also use `\Hyperf\Context\ApplicationContext::getContaienr()` method to obtain the `Container` object.
```php ```php
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
``` ```
## Cautions ## Cautions

View File

@ -24,7 +24,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Etcd\KVInterface; use Hyperf\Etcd\KVInterface;
$client = ApplicationContext::getContainer()->get(KVInterface::class); $client = ApplicationContext::getContainer()->get(KVInterface::class);

View File

@ -414,7 +414,7 @@ Call in the controller
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use App\JsonRpc\CalculatorServiceInterface; use App\JsonRpc\CalculatorServiceInterface;
use App\JsonRpc\MathValue; use App\JsonRpc\MathValue;

View File

@ -132,7 +132,7 @@ Sometimes, you may wish to keep the habit of logging in most frameworks. Then yo
namespace App; namespace App;
use Hyperf\Logger\Logger; use Hyperf\Logger\Logger;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
class Log class Log

View File

@ -393,7 +393,7 @@ Add Prometheus routes in config/routes.php.
use Hyperf\HttpServer\Router\Router; use Hyperf\HttpServer\Router\Router;
Router::get('/metrics', function(){ Router::get('/metrics', function(){
$registry = Hyperf\Utils\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class); $registry = Hyperf\Context\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class);
$renderer = new Prometheus\RenderTextFormat(); $renderer = new Prometheus\RenderTextFormat();
return $renderer->render($registry->getMetricFamilySamples()); return $renderer->render($registry->getMetricFamilySamples());
}); });

View File

@ -251,7 +251,7 @@ For example, when you need to delete a `Topic`, you could execute the following
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Nsq\Nsqd\Topic; use Hyperf\Nsq\Nsqd\Topic;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -140,7 +140,7 @@ When each resource corresponds to a static scene, the proxy class is a good way
```php ```php
<?php <?php
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -13,7 +13,7 @@ The following takes the public account as an example,
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack; use GuzzleHttp\HandlerStack;
@ -98,7 +98,7 @@ return $response->getContent();
```php ```php
<?php <?php
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
$app = Factory::miniProgram([]); $app = Factory::miniProgram([]);

View File

@ -71,7 +71,7 @@ Using `Snowflake` in the framework is very simple. You just need to take out th
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -84,7 +84,7 @@ When you know that the `ID` needs to reverse the corresponding `Meta`, you just
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -132,7 +132,7 @@ class UserDefinedIdGenerator
} }
} }
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(UserDefinedIdGenerator::class); $generator = $container->get(UserDefinedIdGenerator::class);

View File

@ -152,7 +152,7 @@ Obtain the SocketIO singleton directly from the container. This singleton can br
```php ```php
<?php <?php
$io = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class); $io = \Hyperf\Context\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class);
// sending to all clients in'game' room, including sender // sending to all clients in'game' room, including sender
// Push the bigger-announcement event to all connections in the game room. // Push the bigger-announcement event to all connections in the game room.

View File

@ -46,7 +46,7 @@ The Task component provides two usage methods: `active method delivery` and `ann
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\TaskExecutor; use Hyperf\Task\TaskExecutor;
use Hyperf\Task\Task; use Hyperf\Task\Task;
@ -76,7 +76,7 @@ It is not particularly intuitive to use `active method delivery`. Here we implem
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\Annotation\Task; use Hyperf\Task\Annotation\Task;
class AnnotationTask class AnnotationTask
@ -178,7 +178,7 @@ Use as follows
```php ```php
<?php <?php
use App\Task\MongoTask; use App\Task\MongoTask;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$client = ApplicationContext::getContainer()->get(MongoTask::class); $client = ApplicationContext::getContainer()->get(MongoTask::class);
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]); $client->insert('hyperf.test', ['id' => rand(0, 99999999)]);

View File

@ -216,7 +216,7 @@ class UserTest extends HttpTestCase
{ {
public function testUserDaoFirst() public function testUserDaoFirst()
{ {
$model = \Hyperf\Utils\ApplicationContext::getContainer()->get(UserDao::class)->first(1); $model = \Hyperf\Context\ApplicationContext::getContainer()->get(UserDao::class)->first(1);
var_dump($model); var_dump($model);
@ -380,7 +380,7 @@ namespace HyperfTest\Cases;
use App\Api\DemoApi; use App\Api\DemoApi;
use App\Logic\DemoLogic; use App\Logic\DemoLogic;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use HyperfTest\HttpTestCase; use HyperfTest\HttpTestCase;
use Mockery; use Mockery;

View File

@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
<?php <?php
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use App\Amqp\Producers\DemoProducer; use App\Amqp\Producers\DemoProducer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$message = new DemoProducer(1); $message = new DemoProducer(1);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use Hyperf\Command\Annotation\Command; use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
#[Command] #[Command]
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
<?php <?php
use Hyperf\Amqp\Message\DynamicRpcMessage; use Hyperf\Amqp\Message\DynamicRpcMessage;
use Hyperf\Amqp\RpcClient; use Hyperf\Amqp\RpcClient;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class); $rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
// 在 DynamicRpcMessage 上设置与 Consumer 一致的 Exchange 和 RoutingKey // 在 DynamicRpcMessage 上设置与 Consumer 一致的 Exchange 和 RoutingKey

View File

@ -237,7 +237,7 @@ namespace Hyperf\Utils;
use App\Kernel\Context\Coroutine as Co; use App\Kernel\Context\Coroutine as Co;
use Swoole\Coroutine as SwooleCoroutine; use Swoole\Coroutine as SwooleCoroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
/** /**
* @method static void defer(callable $callable) * @method static void defer(callable $callable)

View File

@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
```php ```php
use Hyperf\AsyncQueue\Driver\DriverFactory; use Hyperf\AsyncQueue\Driver\DriverFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other'); $driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
return $driver->push(new ExampleJob()); return $driver->push(new ExampleJob());

View File

@ -2358,7 +2358,7 @@ return [
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = new Container((new DefinitionSourceFactory(true))()); $container = new Container((new DefinitionSourceFactory(true))());

View File

@ -463,7 +463,7 @@ $input = new ArrayInput($params);
$output = new NullOutput(); $output = new NullOutput();
/** @var \Psr\Container\ContainerInterface $container */ /** @var \Psr\Container\ContainerInterface $container */
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
/** @var \Symfony\Component\Console\Application $application */ /** @var \Symfony\Component\Console\Application $application */
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class); $application = $container->get(\Hyperf\Contract\ApplicationInterface::class);

View File

@ -17,7 +17,7 @@ composer require hyperf/consul
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);

View File

@ -235,7 +235,7 @@ try{
```php ```php
<?php <?php
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Coroutine\Concurrent;
$concurrent = new Concurrent(10); $concurrent = new Concurrent(10);

View File

@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\DB\DB; use Hyperf\DB\DB;
$db = ApplicationContext::getContainer()->get(DB::class); $db = ApplicationContext::getContainer()->get(DB::class);

View File

@ -200,7 +200,7 @@ foreach ($books as $book){
```php ```php
use Hyperf\ModelCache\EagerLoad\EagerLoader; use Hyperf\ModelCache\EagerLoad\EagerLoader;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$books = Book::findManyFromCache([1,2,3]); $books = Book::findManyFromCache([1,2,3]);
$loader = ApplicationContext::getContainer()->get(EagerLoader::class); $loader = ApplicationContext::getContainer()->get(EagerLoader::class);

View File

@ -405,10 +405,10 @@ class IndexController
``` ```
在某些更极端动态的情况下,或者非 `容器(Container)` 的管理作用之下时,想要获取到 `容器(Container)` 在某些更极端动态的情况下,或者非 `容器(Container)` 的管理作用之下时,想要获取到 `容器(Container)`
对象还可以通过 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法来获得 `容器(Container)` 对象。 对象还可以通过 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法来获得 `容器(Container)` 对象。
```php ```php
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
``` ```
## 扫描适配器 ## 扫描适配器

View File

@ -24,7 +24,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Etcd\KVInterface; use Hyperf\Etcd\KVInterface;
$client = ApplicationContext::getContainer()->get(KVInterface::class); $client = ApplicationContext::getContainer()->get(KVInterface::class);

View File

@ -444,7 +444,7 @@ interface CalculatorServiceInterface
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use App\JsonRpc\CalculatorServiceInterface; use App\JsonRpc\CalculatorServiceInterface;
use App\JsonRpc\MathValue; use App\JsonRpc\MathValue;

View File

@ -133,7 +133,7 @@ $log->alert('czl');
namespace App; namespace App;
use Hyperf\Logger\LoggerFactory; use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
class Log class Log
{ {

View File

@ -393,7 +393,7 @@ return [
use Hyperf\HttpServer\Router\Router; use Hyperf\HttpServer\Router\Router;
Router::get('/metrics', function(){ Router::get('/metrics', function(){
$registry = Hyperf\Utils\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class); $registry = Hyperf\Context\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class);
$renderer = new Prometheus\RenderTextFormat(); $renderer = new Prometheus\RenderTextFormat();
return $renderer->render($registry->getMetricFamilySamples()); return $renderer->render($registry->getMetricFamilySamples());
}); });

View File

@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Nsq\Nsqd\Topic; use Hyperf\Nsq\Nsqd\Topic;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -111,7 +111,7 @@ namespace App\Controller;
use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\RateLimit\Annotation\RateLimit; use Hyperf\RateLimit\Annotation\RateLimit;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Contract\RequestInterface;
class TestController class TestController

View File

@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
@ -140,7 +140,7 @@ $result = $redis->keys('*');
```php ```php
<?php <?php
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -13,7 +13,7 @@
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack; use GuzzleHttp\HandlerStack;
@ -98,7 +98,7 @@ return $response->getContent();
```php ```php
<?php <?php
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
$app = Factory::miniProgram([]); $app = Factory::miniProgram([]);

View File

@ -71,7 +71,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -84,7 +84,7 @@ $id = $generator->generate();
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
} }
} }
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(UserDefinedIdGenerator::class); $generator = $container->get(UserDefinedIdGenerator::class);

View File

@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
```php ```php
<?php <?php
$io = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class); $io = \Hyperf\Context\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class);
// sending to all clients in 'game' room, including sender // sending to all clients in 'game' room, including sender
// 向 game 房间内的所有连接推送 bigger-announcement 事件。 // 向 game 房间内的所有连接推送 bigger-announcement 事件。

View File

@ -46,7 +46,7 @@ Task 组件提供了 `主动方法投递` 和 `注解投递` 两种使用方法
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\TaskExecutor; use Hyperf\Task\TaskExecutor;
use Hyperf\Task\Task; use Hyperf\Task\Task;
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\Annotation\Task; use Hyperf\Task\Annotation\Task;
class AnnotationTask class AnnotationTask
@ -178,7 +178,7 @@ class MongoTask
```php ```php
<?php <?php
use App\Task\MongoTask; use App\Task\MongoTask;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$client = ApplicationContext::getContainer()->get(MongoTask::class); $client = ApplicationContext::getContainer()->get(MongoTask::class);
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]); $client->insert('hyperf.test', ['id' => rand(0, 99999999)]);

View File

@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
{ {
public function testUserDaoFirst() public function testUserDaoFirst()
{ {
$model = \Hyperf\Utils\ApplicationContext::getContainer()->get(UserDao::class)->first(1); $model = \Hyperf\Context\ApplicationContext::getContainer()->get(UserDao::class)->first(1);
var_dump($model); var_dump($model);
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
use App\Api\DemoApi; use App\Api\DemoApi;
use App\Logic\DemoLogic; use App\Logic\DemoLogic;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use HyperfTest\HttpTestCase; use HyperfTest\HttpTestCase;
use Mockery; use Mockery;

View File

@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
<?php <?php
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use App\Amqp\Producers\DemoProducer; use App\Amqp\Producers\DemoProducer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$message = new DemoProducer(1); $message = new DemoProducer(1);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use Hyperf\Command\Annotation\Command; use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
#[Command] #[Command]
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
<?php <?php
use Hyperf\Amqp\Message\DynamicRpcMessage; use Hyperf\Amqp\Message\DynamicRpcMessage;
use Hyperf\Amqp\RpcClient; use Hyperf\Amqp\RpcClient;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class); $rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
// 在 DynamicRpcMessage 上設置與 Consumer 一致的 Exchange 和 RoutingKey // 在 DynamicRpcMessage 上設置與 Consumer 一致的 Exchange 和 RoutingKey

View File

@ -237,7 +237,7 @@ namespace Hyperf\Utils;
use App\Kernel\Context\Coroutine as Co; use App\Kernel\Context\Coroutine as Co;
use Swoole\Coroutine as SwooleCoroutine; use Swoole\Coroutine as SwooleCoroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
/** /**
* @method static void defer(callable $callable) * @method static void defer(callable $callable)

View File

@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
```php ```php
use Hyperf\AsyncQueue\Driver\DriverFactory; use Hyperf\AsyncQueue\Driver\DriverFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other'); $driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
return $driver->push(new ExampleJob()); return $driver->push(new ExampleJob());

View File

@ -2358,7 +2358,7 @@ return [
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = new Container((new DefinitionSourceFactory(true))()); $container = new Container((new DefinitionSourceFactory(true))());

View File

@ -463,7 +463,7 @@ $input = new ArrayInput($params);
$output = new NullOutput(); $output = new NullOutput();
/** @var \Psr\Container\ContainerInterface $container */ /** @var \Psr\Container\ContainerInterface $container */
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
/** @var \Symfony\Component\Console\Application $application */ /** @var \Symfony\Component\Console\Application $application */
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class); $application = $container->get(\Hyperf\Contract\ApplicationInterface::class);

View File

@ -17,7 +17,7 @@ composer require hyperf/consul
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);

View File

@ -235,7 +235,7 @@ try{
```php ```php
<?php <?php
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Coroutine\Concurrent;
$concurrent = new Concurrent(10); $concurrent = new Concurrent(10);

View File

@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\DB\DB; use Hyperf\DB\DB;
$db = ApplicationContext::getContainer()->get(DB::class); $db = ApplicationContext::getContainer()->get(DB::class);

View File

@ -200,7 +200,7 @@ foreach ($books as $book){
```php ```php
use Hyperf\ModelCache\EagerLoad\EagerLoader; use Hyperf\ModelCache\EagerLoad\EagerLoader;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$books = Book::findManyFromCache([1,2,3]); $books = Book::findManyFromCache([1,2,3]);
$loader = ApplicationContext::getContainer()->get(EagerLoader::class); $loader = ApplicationContext::getContainer()->get(EagerLoader::class);

View File

@ -405,10 +405,10 @@ class IndexController
``` ```
在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)` 在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)`
對象還可以通過 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 對象。 對象還可以通過 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 對象。
```php ```php
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
``` ```
## 掃描適配器 ## 掃描適配器

View File

@ -24,7 +24,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Etcd\KVInterface; use Hyperf\Etcd\KVInterface;
$client = ApplicationContext::getContainer()->get(KVInterface::class); $client = ApplicationContext::getContainer()->get(KVInterface::class);

View File

@ -444,7 +444,7 @@ interface CalculatorServiceInterface
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use App\JsonRpc\CalculatorServiceInterface; use App\JsonRpc\CalculatorServiceInterface;
use App\JsonRpc\MathValue; use App\JsonRpc\MathValue;

View File

@ -133,7 +133,7 @@ $log->alert('czl');
namespace App; namespace App;
use Hyperf\Logger\LoggerFactory; use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
class Log class Log
{ {

View File

@ -393,7 +393,7 @@ return [
use Hyperf\HttpServer\Router\Router; use Hyperf\HttpServer\Router\Router;
Router::get('/metrics', function(){ Router::get('/metrics', function(){
$registry = Hyperf\Utils\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class); $registry = Hyperf\Context\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class);
$renderer = new Prometheus\RenderTextFormat(); $renderer = new Prometheus\RenderTextFormat();
return $renderer->render($registry->getMetricFamilySamples()); return $renderer->render($registry->getMetricFamilySamples());
}); });

View File

@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Nsq\Nsqd\Topic; use Hyperf\Nsq\Nsqd\Topic;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -111,7 +111,7 @@ namespace App\Controller;
use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\RateLimit\Annotation\RateLimit; use Hyperf\RateLimit\Annotation\RateLimit;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Contract\RequestInterface;
class TestController class TestController

View File

@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
@ -140,7 +140,7 @@ $result = $redis->keys('*');
```php ```php
<?php <?php
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -13,7 +13,7 @@
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack; use GuzzleHttp\HandlerStack;
@ -98,7 +98,7 @@ return $response->getContent();
```php ```php
<?php <?php
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
$app = Factory::miniProgram([]); $app = Factory::miniProgram([]);

View File

@ -71,7 +71,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -84,7 +84,7 @@ $id = $generator->generate();
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
} }
} }
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(UserDefinedIdGenerator::class); $generator = $container->get(UserDefinedIdGenerator::class);

View File

@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
```php ```php
<?php <?php
$io = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class); $io = \Hyperf\Context\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class);
// sending to all clients in 'game' room, including sender // sending to all clients in 'game' room, including sender
// 向 game 房間內的所有連接推送 bigger-announcement 事件。 // 向 game 房間內的所有連接推送 bigger-announcement 事件。

View File

@ -46,7 +46,7 @@ Task 組件提供了 `主動方法投遞` 和 `註解投遞` 兩種使用方法
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\TaskExecutor; use Hyperf\Task\TaskExecutor;
use Hyperf\Task\Task; use Hyperf\Task\Task;
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\Annotation\Task; use Hyperf\Task\Annotation\Task;
class AnnotationTask class AnnotationTask
@ -178,7 +178,7 @@ class MongoTask
```php ```php
<?php <?php
use App\Task\MongoTask; use App\Task\MongoTask;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$client = ApplicationContext::getContainer()->get(MongoTask::class); $client = ApplicationContext::getContainer()->get(MongoTask::class);
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]); $client->insert('hyperf.test', ['id' => rand(0, 99999999)]);

View File

@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
{ {
public function testUserDaoFirst() public function testUserDaoFirst()
{ {
$model = \Hyperf\Utils\ApplicationContext::getContainer()->get(UserDao::class)->first(1); $model = \Hyperf\Context\ApplicationContext::getContainer()->get(UserDao::class)->first(1);
var_dump($model); var_dump($model);
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
use App\Api\DemoApi; use App\Api\DemoApi;
use App\Logic\DemoLogic; use App\Logic\DemoLogic;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use HyperfTest\HttpTestCase; use HyperfTest\HttpTestCase;
use Mockery; use Mockery;

View File

@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
<?php <?php
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use App\Amqp\Producers\DemoProducer; use App\Amqp\Producers\DemoProducer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$message = new DemoProducer(1); $message = new DemoProducer(1);
$producer = ApplicationContext::getContainer()->get(Producer::class); $producer = ApplicationContext::getContainer()->get(Producer::class);
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
use Hyperf\Amqp\Producer; use Hyperf\Amqp\Producer;
use Hyperf\Command\Annotation\Command; use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
#[Command] #[Command]
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
<?php <?php
use Hyperf\Amqp\Message\DynamicRpcMessage; use Hyperf\Amqp\Message\DynamicRpcMessage;
use Hyperf\Amqp\RpcClient; use Hyperf\Amqp\RpcClient;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class); $rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
// 在 DynamicRpcMessage 上設定與 Consumer 一致的 Exchange 和 RoutingKey // 在 DynamicRpcMessage 上設定與 Consumer 一致的 Exchange 和 RoutingKey

View File

@ -237,7 +237,7 @@ namespace Hyperf\Utils;
use App\Kernel\Context\Coroutine as Co; use App\Kernel\Context\Coroutine as Co;
use Swoole\Coroutine as SwooleCoroutine; use Swoole\Coroutine as SwooleCoroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
/** /**
* @method static void defer(callable $callable) * @method static void defer(callable $callable)

View File

@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
```php ```php
use Hyperf\AsyncQueue\Driver\DriverFactory; use Hyperf\AsyncQueue\Driver\DriverFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other'); $driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
return $driver->push(new ExampleJob()); return $driver->push(new ExampleJob());

View File

@ -2358,7 +2358,7 @@ return [
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Di\Definition\DefinitionSourceFactory; use Hyperf\Di\Definition\DefinitionSourceFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = new Container((new DefinitionSourceFactory(true))()); $container = new Container((new DefinitionSourceFactory(true))());

View File

@ -463,7 +463,7 @@ $input = new ArrayInput($params);
$output = new NullOutput(); $output = new NullOutput();
/** @var \Psr\Container\ContainerInterface $container */ /** @var \Psr\Container\ContainerInterface $container */
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
/** @var \Symfony\Component\Console\Application $application */ /** @var \Symfony\Component\Console\Application $application */
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class); $application = $container->get(\Hyperf\Contract\ApplicationInterface::class);

View File

@ -17,7 +17,7 @@ composer require hyperf/consul
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
```php ```php
use Hyperf\Consul\KV; use Hyperf\Consul\KV;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$clientFactory = $container->get(ClientFactory::class); $clientFactory = $container->get(ClientFactory::class);

View File

@ -235,7 +235,7 @@ try{
```php ```php
<?php <?php
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Coroutine\Concurrent;
$concurrent = new Concurrent(10); $concurrent = new Concurrent(10);

View File

@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\DB\DB; use Hyperf\DB\DB;
$db = ApplicationContext::getContainer()->get(DB::class); $db = ApplicationContext::getContainer()->get(DB::class);

View File

@ -200,7 +200,7 @@ foreach ($books as $book){
```php ```php
use Hyperf\ModelCache\EagerLoad\EagerLoader; use Hyperf\ModelCache\EagerLoad\EagerLoader;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$books = Book::findManyFromCache([1,2,3]); $books = Book::findManyFromCache([1,2,3]);
$loader = ApplicationContext::getContainer()->get(EagerLoader::class); $loader = ApplicationContext::getContainer()->get(EagerLoader::class);

View File

@ -405,10 +405,10 @@ class IndexController
``` ```
在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)` 在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)`
物件還可以透過 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 物件。 物件還可以透過 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 物件。
```php ```php
$container = \Hyperf\Utils\ApplicationContext::getContainer(); $container = \Hyperf\Context\ApplicationContext::getContainer();
``` ```
## 掃描介面卡 ## 掃描介面卡

View File

@ -24,7 +24,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Etcd\KVInterface; use Hyperf\Etcd\KVInterface;
$client = ApplicationContext::getContainer()->get(KVInterface::class); $client = ApplicationContext::getContainer()->get(KVInterface::class);

View File

@ -444,7 +444,7 @@ interface CalculatorServiceInterface
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use App\JsonRpc\CalculatorServiceInterface; use App\JsonRpc\CalculatorServiceInterface;
use App\JsonRpc\MathValue; use App\JsonRpc\MathValue;

View File

@ -133,7 +133,7 @@ $log->alert('czl');
namespace App; namespace App;
use Hyperf\Logger\LoggerFactory; use Hyperf\Logger\LoggerFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
class Log class Log
{ {

View File

@ -393,7 +393,7 @@ return [
use Hyperf\HttpServer\Router\Router; use Hyperf\HttpServer\Router\Router;
Router::get('/metrics', function(){ Router::get('/metrics', function(){
$registry = Hyperf\Utils\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class); $registry = Hyperf\Context\ApplicationContext::getContainer()->get(Prometheus\CollectorRegistry::class);
$renderer = new Prometheus\RenderTextFormat(); $renderer = new Prometheus\RenderTextFormat();
return $renderer->render($registry->getMetricFamilySamples()); return $renderer->render($registry->getMetricFamilySamples());
}); });

View File

@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Nsq\Nsqd\Topic; use Hyperf\Nsq\Nsqd\Topic;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -111,7 +111,7 @@ namespace App\Controller;
use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\RateLimit\Annotation\RateLimit; use Hyperf\RateLimit\Annotation\RateLimit;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Contract\RequestInterface;
class TestController class TestController

View File

@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
@ -140,7 +140,7 @@ $result = $redis->keys('*');
```php ```php
<?php <?php
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();

View File

@ -13,7 +13,7 @@
```php ```php
<?php <?php
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack; use GuzzleHttp\HandlerStack;
@ -98,7 +98,7 @@ return $response->getContent();
```php ```php
<?php <?php
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use EasyWeChat\Factory; use EasyWeChat\Factory;
$app = Factory::miniProgram([]); $app = Factory::miniProgram([]);

View File

@ -71,7 +71,7 @@ return [
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -84,7 +84,7 @@ $id = $generator->generate();
```php ```php
<?php <?php
use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(IdGeneratorInterface::class); $generator = $container->get(IdGeneratorInterface::class);
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
} }
} }
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$container = ApplicationContext::getContainer(); $container = ApplicationContext::getContainer();
$generator = $container->get(UserDefinedIdGenerator::class); $generator = $container->get(UserDefinedIdGenerator::class);

View File

@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
```php ```php
<?php <?php
$io = \Hyperf\Utils\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class); $io = \Hyperf\Context\ApplicationContext::getContainer()->get(\Hyperf\SocketIOServer\SocketIO::class);
// sending to all clients in 'game' room, including sender // sending to all clients in 'game' room, including sender
// 向 game 房間內的所有連線推送 bigger-announcement 事件。 // 向 game 房間內的所有連線推送 bigger-announcement 事件。

View File

@ -46,7 +46,7 @@ Task 元件提供了 `主動方法投遞` 和 `註解投遞` 兩種使用方法
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\TaskExecutor; use Hyperf\Task\TaskExecutor;
use Hyperf\Task\Task; use Hyperf\Task\Task;
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
<?php <?php
use Hyperf\Utils\Coroutine; use Hyperf\Utils\Coroutine;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Task\Annotation\Task; use Hyperf\Task\Annotation\Task;
class AnnotationTask class AnnotationTask
@ -178,7 +178,7 @@ class MongoTask
```php ```php
<?php <?php
use App\Task\MongoTask; use App\Task\MongoTask;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
$client = ApplicationContext::getContainer()->get(MongoTask::class); $client = ApplicationContext::getContainer()->get(MongoTask::class);
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]); $client->insert('hyperf.test', ['id' => rand(0, 99999999)]);

View File

@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
{ {
public function testUserDaoFirst() public function testUserDaoFirst()
{ {
$model = \Hyperf\Utils\ApplicationContext::getContainer()->get(UserDao::class)->first(1); $model = \Hyperf\Context\ApplicationContext::getContainer()->get(UserDao::class)->first(1);
var_dump($model); var_dump($model);
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
use App\Api\DemoApi; use App\Api\DemoApi;
use App\Logic\DemoLogic; use App\Logic\DemoLogic;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use HyperfTest\HttpTestCase; use HyperfTest\HttpTestCase;
use Mockery; use Mockery;

View File

@ -20,9 +20,9 @@ use Hyperf\Amqp\Message\ConsumerMessageInterface;
use Hyperf\Amqp\Message\MessageInterface; use Hyperf\Amqp\Message\MessageInterface;
use Hyperf\Amqp\Message\Type; use Hyperf\Amqp\Message\Type;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\Coroutine\Concurrent;
use Hyperf\ExceptionHandler\Formatter\FormatterInterface; use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
use Hyperf\Process\ProcessManager; use Hyperf\Process\ProcessManager;
use Hyperf\Utils\Coroutine\Concurrent;
use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Exception\AMQPTimeoutException; use PhpAmqpLib\Exception\AMQPTimeoutException;
use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Message\AMQPMessage;

View File

@ -14,7 +14,7 @@ namespace Hyperf\Amqp\Message;
use Hyperf\Amqp\Builder\QueueBuilder; use Hyperf\Amqp\Builder\QueueBuilder;
use Hyperf\Amqp\Packer\Packer; use Hyperf\Amqp\Packer\Packer;
use Hyperf\Amqp\Result; use Hyperf\Amqp\Result;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Message\AMQPMessage;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;

View File

@ -13,7 +13,7 @@ namespace Hyperf\Amqp\Message;
use Hyperf\Amqp\Constants; use Hyperf\Amqp\Constants;
use Hyperf\Amqp\Packer\Packer; use Hyperf\Amqp\Packer\Packer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
abstract class ProducerMessage extends Message implements ProducerMessageInterface abstract class ProducerMessage extends Message implements ProducerMessageInterface
{ {

View File

@ -13,7 +13,7 @@ namespace Hyperf\Amqp\Message;
use Hyperf\Amqp\Builder\QueueBuilder; use Hyperf\Amqp\Builder\QueueBuilder;
use Hyperf\Amqp\Packer\Packer; use Hyperf\Amqp\Packer\Packer;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
abstract class RpcMessage extends Message implements RpcMessageInterface abstract class RpcMessage extends Message implements RpcMessageInterface
{ {

View File

@ -13,7 +13,7 @@ namespace HyperfTest\Amqp;
use Hyperf\Amqp\ConnectionFactory; use Hyperf\Amqp\ConnectionFactory;
use Hyperf\Amqp\Consumer; use Hyperf\Amqp\Consumer;
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Coroutine\Concurrent;
use Hyperf\Utils\Exception\ChannelClosedException; use Hyperf\Utils\Exception\ChannelClosedException;
use Hyperf\Utils\Reflection\ClassInvoker; use Hyperf\Utils\Reflection\ClassInvoker;
use HyperfTest\Amqp\Stub\AMQPConnectionStub; use HyperfTest\Amqp\Stub\AMQPConnectionStub;

View File

@ -16,12 +16,12 @@ use Hyperf\Amqp\Consumer;
use Hyperf\Amqp\IO\IOFactory; use Hyperf\Amqp\IO\IOFactory;
use Hyperf\Amqp\Pool\PoolFactory; use Hyperf\Amqp\Pool\PoolFactory;
use Hyperf\Config\Config; use Hyperf\Config\Config;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\ExceptionHandler\Formatter\DefaultFormatter; use Hyperf\ExceptionHandler\Formatter\DefaultFormatter;
use Hyperf\ExceptionHandler\Formatter\FormatterInterface; use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
use Hyperf\Utils\ApplicationContext;
use Mockery; use Mockery;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;

View File

@ -11,9 +11,9 @@ declare(strict_types=1);
*/ */
namespace Hyperf\AsyncQueue; namespace Hyperf\AsyncQueue;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\CompressInterface; use Hyperf\Contract\CompressInterface;
use Hyperf\Contract\UnCompressInterface; use Hyperf\Contract\UnCompressInterface;
use Hyperf\Utils\ApplicationContext;
class AnnotationJob extends Job class AnnotationJob extends Job
{ {

View File

@ -20,8 +20,8 @@ use Hyperf\AsyncQueue\MessageInterface;
use Hyperf\Collection\Arr; use Hyperf\Collection\Arr;
use Hyperf\Contract\PackerInterface; use Hyperf\Contract\PackerInterface;
use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Coroutine\Concurrent;
use Hyperf\Process\ProcessManager; use Hyperf\Process\ProcessManager;
use Hyperf\Utils\Coroutine\Concurrent;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;

View File

@ -17,12 +17,12 @@ use Hyperf\AsyncQueue\Aspect\AsyncQueueAspect;
use Hyperf\AsyncQueue\Driver\DriverFactory; use Hyperf\AsyncQueue\Driver\DriverFactory;
use Hyperf\AsyncQueue\Driver\DriverInterface; use Hyperf\AsyncQueue\Driver\DriverInterface;
use Hyperf\AsyncQueue\Environment; use Hyperf\AsyncQueue\Environment;
use Hyperf\Context\ApplicationContext;
use Hyperf\Context\Context; use Hyperf\Context\Context;
use Hyperf\Di\Annotation\AnnotationCollector; use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Annotation\Aspect;
use Hyperf\Di\Aop\Ast; use Hyperf\Di\Aop\Ast;
use Hyperf\Di\ReflectionManager; use Hyperf\Di\ReflectionManager;
use Hyperf\Utils\ApplicationContext;
use HyperfTest\AsyncQueue\Stub\FooProxy; use HyperfTest\AsyncQueue\Stub\FooProxy;
use Mockery; use Mockery;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View File

@ -12,10 +12,10 @@ declare(strict_types=1);
namespace HyperfTest\AsyncQueue; namespace HyperfTest\AsyncQueue;
use Hyperf\AsyncQueue\Driver\ChannelConfig; use Hyperf\AsyncQueue\Driver\ChannelConfig;
use Hyperf\Context\ApplicationContext;
use Hyperf\Coroutine\Concurrent;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Coroutine\Concurrent;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use HyperfTest\AsyncQueue\Stub\Redis; use HyperfTest\AsyncQueue\Stub\Redis;
use HyperfTest\AsyncQueue\Stub\RedisDriverStub; use HyperfTest\AsyncQueue\Stub\RedisDriverStub;

View File

@ -15,10 +15,10 @@ use Hyperf\AsyncQueue\Driver\ChannelConfig;
use Hyperf\AsyncQueue\Driver\RedisDriver; use Hyperf\AsyncQueue\Driver\RedisDriver;
use Hyperf\AsyncQueue\JobMessage; use Hyperf\AsyncQueue\JobMessage;
use Hyperf\AsyncQueue\Message; use Hyperf\AsyncQueue\Message;
use Hyperf\Context\ApplicationContext;
use Hyperf\Context\Context; use Hyperf\Context\Context;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use Hyperf\Utils\Str; use Hyperf\Utils\Str;
use HyperfTest\AsyncQueue\Stub\DemoJob; use HyperfTest\AsyncQueue\Stub\DemoJob;

View File

@ -12,7 +12,7 @@ declare(strict_types=1);
namespace HyperfTest\AsyncQueue\Stub; namespace HyperfTest\AsyncQueue\Stub;
use Hyperf\AsyncQueue\Driver\RedisDriver; use Hyperf\AsyncQueue\Driver\RedisDriver;
use Hyperf\Utils\Coroutine\Concurrent; use Hyperf\Coroutine\Concurrent;
class RedisDriverStub extends RedisDriver class RedisDriverStub extends RedisDriver
{ {

View File

@ -14,9 +14,9 @@ namespace HyperfTest\Cache\Cases;
use Hyperf\Cache\CacheManager; use Hyperf\Cache\CacheManager;
use Hyperf\Cache\Driver\FileSystemDriver; use Hyperf\Cache\Driver\FileSystemDriver;
use Hyperf\Config\Config; use Hyperf\Config\Config;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Container; use Hyperf\Di\Container;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Filesystem\Filesystem; use Hyperf\Utils\Filesystem\Filesystem;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use HyperfTest\Cache\Stub\Foo; use HyperfTest\Cache\Stub\Foo;

View File

@ -16,6 +16,7 @@ use Hyperf\Cache\CacheManager;
use Hyperf\Cache\Driver\KeyCollectorInterface; use Hyperf\Cache\Driver\KeyCollectorInterface;
use Hyperf\Cache\Driver\RedisDriver; use Hyperf\Cache\Driver\RedisDriver;
use Hyperf\Config\Config; use Hyperf\Config\Config;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Container; use Hyperf\Di\Container;
@ -28,7 +29,6 @@ use Hyperf\Redis\Pool\RedisPool;
use Hyperf\Redis\Redis; use Hyperf\Redis\Redis;
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Redis\RedisProxy; use Hyperf\Redis\RedisProxy;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use HyperfTest\Cache\Stub\Foo; use HyperfTest\Cache\Stub\Foo;
use HyperfTest\Cache\Stub\SerializeRedisDriver; use HyperfTest\Cache\Stub\SerializeRedisDriver;

View File

@ -14,6 +14,7 @@ namespace HyperfTest\Cache\Stub;
use Hyperf\Cache\CacheManager; use Hyperf\Cache\CacheManager;
use Hyperf\Cache\Driver\RedisDriver; use Hyperf\Cache\Driver\RedisDriver;
use Hyperf\Config\Config; use Hyperf\Config\Config;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface; use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Container; use Hyperf\Di\Container;
@ -26,7 +27,6 @@ use Hyperf\Redis\Pool\RedisPool;
use Hyperf\Redis\Redis; use Hyperf\Redis\Redis;
use Hyperf\Redis\RedisFactory; use Hyperf\Redis\RedisFactory;
use Hyperf\Redis\RedisProxy; use Hyperf\Redis\RedisProxy;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\Packer\PhpSerializerPacker; use Hyperf\Utils\Packer\PhpSerializerPacker;
use Mockery; use Mockery;

View File

@ -11,7 +11,7 @@ declare(strict_types=1);
*/ */
namespace Hyperf\Command; namespace Hyperf\Command;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;

View File

@ -11,7 +11,7 @@ declare(strict_types=1);
*/ */
namespace HyperfTest\Command; namespace HyperfTest\Command;
use Hyperf\Utils\ApplicationContext; use Hyperf\Context\ApplicationContext;
use Hyperf\Utils\Reflection\ClassInvoker; use Hyperf\Utils\Reflection\ClassInvoker;
use HyperfTest\Command\Command\DefaultSwooleFlagsCommand; use HyperfTest\Command\Command\DefaultSwooleFlagsCommand;
use HyperfTest\Command\Command\FooCommand; use HyperfTest\Command\Command\FooCommand;

View File

@ -14,9 +14,9 @@ namespace HyperfTest\ConfigApollo;
use Hyperf\Config\Config; use Hyperf\Config\Config;
use Hyperf\ConfigApollo\Client; use Hyperf\ConfigApollo\Client;
use Hyperf\ConfigApollo\Option; use Hyperf\ConfigApollo\Option;
use Hyperf\Context\ApplicationContext;
use Hyperf\Contract\ConfigInterface; use Hyperf\Contract\ConfigInterface;
use Hyperf\Guzzle\ClientFactory; use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\ApplicationContext;
use Mockery; use Mockery;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;

Some files were not shown because too many files have changed in this diff Show More