mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Use Hyperf\Context\ApplicationContext
instead of Hyperf\Utils\ApplicationContext
. (#5621)
This commit is contained in:
parent
7d97774f99
commit
c422dad528
@ -6,6 +6,7 @@
|
||||
- [#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.
|
||||
- [#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
|
||||
|
||||
|
@ -77,7 +77,7 @@ Get the Producer instance through container, and you can deliver the message. It
|
||||
<?php
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producers\DemoProducer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$message = new DemoProducer(1);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
|
@ -2619,7 +2619,7 @@ config/container.php
|
||||
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = new Container((new DefinitionSourceFactory(true))());
|
||||
|
||||
|
@ -61,7 +61,7 @@ The specific interface can be viewed `Hyperf\DB\ConnectionInterface`。
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\DB\DB;
|
||||
|
||||
$db = ApplicationContext::getContainer()->get(DB::class);
|
||||
|
@ -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
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
```
|
||||
|
||||
## Cautions
|
||||
|
@ -24,7 +24,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Etcd\KVInterface;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(KVInterface::class);
|
||||
|
@ -414,7 +414,7 @@ Call in the controller
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use App\JsonRpc\CalculatorServiceInterface;
|
||||
use App\JsonRpc\MathValue;
|
||||
|
||||
|
@ -132,7 +132,7 @@ Sometimes, you may wish to keep the habit of logging in most frameworks. Then yo
|
||||
namespace App;
|
||||
|
||||
use Hyperf\Logger\Logger;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
|
||||
class Log
|
||||
|
@ -393,7 +393,7 @@ Add Prometheus routes in config/routes.php.
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
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();
|
||||
return $renderer->render($registry->getMetricFamilySamples());
|
||||
});
|
||||
|
@ -251,7 +251,7 @@ For example, when you need to delete a `Topic`, you could execute the following
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Nsq\Nsqd\Topic;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
@ -140,7 +140,7 @@ When each resource corresponds to a static scene, the proxy class is a good way
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
|
@ -13,7 +13,7 @@ The following takes the public account as an example,
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
@ -98,7 +98,7 @@ return $response->getContent();
|
||||
```php
|
||||
<?php
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
$app = Factory::miniProgram([]);
|
||||
|
@ -71,7 +71,7 @@ Using `Snowflake` in the framework is very simple. You just need to take out th
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$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
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -132,7 +132,7 @@ class UserDefinedIdGenerator
|
||||
}
|
||||
}
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(UserDefinedIdGenerator::class);
|
||||
|
@ -152,7 +152,7 @@ Obtain the SocketIO singleton directly from the container. This singleton can br
|
||||
|
||||
```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
|
||||
// Push the bigger-announcement event to all connections in the game room.
|
||||
|
@ -46,7 +46,7 @@ The Task component provides two usage methods: `active method delivery` and `ann
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\TaskExecutor;
|
||||
use Hyperf\Task\Task;
|
||||
|
||||
@ -76,7 +76,7 @@ It is not particularly intuitive to use `active method delivery`. Here we implem
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\Annotation\Task;
|
||||
|
||||
class AnnotationTask
|
||||
@ -178,7 +178,7 @@ Use as follows
|
||||
```php
|
||||
<?php
|
||||
use App\Task\MongoTask;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(MongoTask::class);
|
||||
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]);
|
||||
|
@ -216,7 +216,7 @@ class UserTest extends HttpTestCase
|
||||
{
|
||||
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);
|
||||
|
||||
@ -380,7 +380,7 @@ namespace HyperfTest\Cases;
|
||||
use App\Api\DemoApi;
|
||||
use App\Logic\DemoLogic;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use HyperfTest\HttpTestCase;
|
||||
use Mockery;
|
||||
|
||||
|
@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producers\DemoProducer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$message = new DemoProducer(1);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Message\DynamicRpcMessage;
|
||||
use Hyperf\Amqp\RpcClient;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
|
||||
// 在 DynamicRpcMessage 上设置与 Consumer 一致的 Exchange 和 RoutingKey
|
||||
|
@ -237,7 +237,7 @@ namespace Hyperf\Utils;
|
||||
|
||||
use App\Kernel\Context\Coroutine as Co;
|
||||
use Swoole\Coroutine as SwooleCoroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
/**
|
||||
* @method static void defer(callable $callable)
|
||||
|
@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
|
||||
|
||||
```php
|
||||
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
|
||||
return $driver->push(new ExampleJob());
|
||||
|
@ -2358,7 +2358,7 @@ return [
|
||||
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = new Container((new DefinitionSourceFactory(true))());
|
||||
|
||||
|
@ -463,7 +463,7 @@ $input = new ArrayInput($params);
|
||||
$output = new NullOutput();
|
||||
|
||||
/** @var \Psr\Container\ContainerInterface $container */
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
|
||||
/** @var \Symfony\Component\Console\Application $application */
|
||||
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
|
||||
|
@ -17,7 +17,7 @@ composer require hyperf/consul
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -119,4 +119,4 @@ $response = $kv->get($namespace, ['token' => 'your-token'])->json();
|
||||
- info($sessionId, array $options = []): ConsulResponse
|
||||
- node($node, array $options = []): ConsulResponse
|
||||
- all(array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
|
@ -235,7 +235,7 @@ try{
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
|
||||
$concurrent = new Concurrent(10);
|
||||
|
||||
|
@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\DB\DB;
|
||||
|
||||
$db = ApplicationContext::getContainer()->get(DB::class);
|
||||
|
@ -200,7 +200,7 @@ foreach ($books as $book){
|
||||
|
||||
```php
|
||||
use Hyperf\ModelCache\EagerLoad\EagerLoader;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$books = Book::findManyFromCache([1,2,3]);
|
||||
$loader = ApplicationContext::getContainer()->get(EagerLoader::class);
|
||||
|
@ -405,10 +405,10 @@ class IndexController
|
||||
```
|
||||
|
||||
在某些更极端动态的情况下,或者非 `容器(Container)` 的管理作用之下时,想要获取到 `容器(Container)`
|
||||
对象还可以通过 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法来获得 `容器(Container)` 对象。
|
||||
对象还可以通过 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法来获得 `容器(Container)` 对象。
|
||||
|
||||
```php
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
```
|
||||
|
||||
## 扫描适配器
|
||||
|
@ -24,7 +24,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Etcd\KVInterface;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(KVInterface::class);
|
||||
|
@ -444,7 +444,7 @@ interface CalculatorServiceInterface
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use App\JsonRpc\CalculatorServiceInterface;
|
||||
use App\JsonRpc\MathValue;
|
||||
|
||||
|
@ -133,7 +133,7 @@ $log->alert('czl');
|
||||
namespace App;
|
||||
|
||||
use Hyperf\Logger\LoggerFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
class Log
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ return [
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
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();
|
||||
return $renderer->render($registry->getMetricFamilySamples());
|
||||
});
|
||||
|
@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Nsq\Nsqd\Topic;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
@ -111,7 +111,7 @@ namespace App\Controller;
|
||||
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Hyperf\RateLimit\Annotation\RateLimit;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
class TestController
|
||||
|
@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
@ -140,7 +140,7 @@ $result = $redis->keys('*');
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
@ -98,7 +98,7 @@ return $response->getContent();
|
||||
```php
|
||||
<?php
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
$app = Factory::miniProgram([]);
|
||||
|
@ -71,7 +71,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -84,7 +84,7 @@ $id = $generator->generate();
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
|
||||
}
|
||||
}
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(UserDefinedIdGenerator::class);
|
||||
|
@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
|
||||
|
||||
```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
|
||||
// 向 game 房间内的所有连接推送 bigger-announcement 事件。
|
||||
|
@ -46,7 +46,7 @@ Task 组件提供了 `主动方法投递` 和 `注解投递` 两种使用方法
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\TaskExecutor;
|
||||
use Hyperf\Task\Task;
|
||||
|
||||
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\Annotation\Task;
|
||||
|
||||
class AnnotationTask
|
||||
@ -178,7 +178,7 @@ class MongoTask
|
||||
```php
|
||||
<?php
|
||||
use App\Task\MongoTask;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(MongoTask::class);
|
||||
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]);
|
||||
|
@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
|
||||
{
|
||||
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);
|
||||
|
||||
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
|
||||
use App\Api\DemoApi;
|
||||
use App\Logic\DemoLogic;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use HyperfTest\HttpTestCase;
|
||||
use Mockery;
|
||||
|
||||
|
@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producers\DemoProducer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$message = new DemoProducer(1);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Message\DynamicRpcMessage;
|
||||
use Hyperf\Amqp\RpcClient;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
|
||||
// 在 DynamicRpcMessage 上設置與 Consumer 一致的 Exchange 和 RoutingKey
|
||||
|
@ -237,7 +237,7 @@ namespace Hyperf\Utils;
|
||||
|
||||
use App\Kernel\Context\Coroutine as Co;
|
||||
use Swoole\Coroutine as SwooleCoroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
/**
|
||||
* @method static void defer(callable $callable)
|
||||
|
@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
|
||||
|
||||
```php
|
||||
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
|
||||
return $driver->push(new ExampleJob());
|
||||
|
@ -2358,7 +2358,7 @@ return [
|
||||
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = new Container((new DefinitionSourceFactory(true))());
|
||||
|
||||
|
@ -463,7 +463,7 @@ $input = new ArrayInput($params);
|
||||
$output = new NullOutput();
|
||||
|
||||
/** @var \Psr\Container\ContainerInterface $container */
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
|
||||
/** @var \Symfony\Component\Console\Application $application */
|
||||
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
|
||||
|
@ -17,7 +17,7 @@ composer require hyperf/consul
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -119,4 +119,4 @@ $response = $kv->get($namespace, ['token' => 'your-token'])->json();
|
||||
- info($sessionId, array $options = []): ConsulResponse
|
||||
- node($node, array $options = []): ConsulResponse
|
||||
- all(array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
|
@ -235,7 +235,7 @@ try{
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
|
||||
$concurrent = new Concurrent(10);
|
||||
|
||||
|
@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\DB\DB;
|
||||
|
||||
$db = ApplicationContext::getContainer()->get(DB::class);
|
||||
|
@ -200,7 +200,7 @@ foreach ($books as $book){
|
||||
|
||||
```php
|
||||
use Hyperf\ModelCache\EagerLoad\EagerLoader;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$books = Book::findManyFromCache([1,2,3]);
|
||||
$loader = ApplicationContext::getContainer()->get(EagerLoader::class);
|
||||
|
@ -405,10 +405,10 @@ class IndexController
|
||||
```
|
||||
|
||||
在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)`
|
||||
對象還可以通過 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 對象。
|
||||
對象還可以通過 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 對象。
|
||||
|
||||
```php
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
```
|
||||
|
||||
## 掃描適配器
|
||||
|
@ -24,7 +24,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Etcd\KVInterface;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(KVInterface::class);
|
||||
|
@ -444,7 +444,7 @@ interface CalculatorServiceInterface
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use App\JsonRpc\CalculatorServiceInterface;
|
||||
use App\JsonRpc\MathValue;
|
||||
|
||||
|
@ -133,7 +133,7 @@ $log->alert('czl');
|
||||
namespace App;
|
||||
|
||||
use Hyperf\Logger\LoggerFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
class Log
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ return [
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
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();
|
||||
return $renderer->render($registry->getMetricFamilySamples());
|
||||
});
|
||||
|
@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Nsq\Nsqd\Topic;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
@ -111,7 +111,7 @@ namespace App\Controller;
|
||||
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Hyperf\RateLimit\Annotation\RateLimit;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
class TestController
|
||||
|
@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
@ -140,7 +140,7 @@ $result = $redis->keys('*');
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
@ -98,7 +98,7 @@ return $response->getContent();
|
||||
```php
|
||||
<?php
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
$app = Factory::miniProgram([]);
|
||||
|
@ -71,7 +71,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -84,7 +84,7 @@ $id = $generator->generate();
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
|
||||
}
|
||||
}
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(UserDefinedIdGenerator::class);
|
||||
|
@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
|
||||
|
||||
```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
|
||||
// 向 game 房間內的所有連接推送 bigger-announcement 事件。
|
||||
|
@ -46,7 +46,7 @@ Task 組件提供了 `主動方法投遞` 和 `註解投遞` 兩種使用方法
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\TaskExecutor;
|
||||
use Hyperf\Task\Task;
|
||||
|
||||
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\Annotation\Task;
|
||||
|
||||
class AnnotationTask
|
||||
@ -178,7 +178,7 @@ class MongoTask
|
||||
```php
|
||||
<?php
|
||||
use App\Task\MongoTask;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(MongoTask::class);
|
||||
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]);
|
||||
|
@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
|
||||
{
|
||||
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);
|
||||
|
||||
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
|
||||
use App\Api\DemoApi;
|
||||
use App\Logic\DemoLogic;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use HyperfTest\HttpTestCase;
|
||||
use Mockery;
|
||||
|
||||
|
@ -108,7 +108,7 @@ class DemoProducer extends ProducerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producers\DemoProducer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$message = new DemoProducer(1);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
@ -320,7 +320,7 @@ use App\Amqp\Producer\DelayDirectProducer;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
@ -404,7 +404,7 @@ class ReplyConsumer extends ConsumerMessage
|
||||
<?php
|
||||
use Hyperf\Amqp\Message\DynamicRpcMessage;
|
||||
use Hyperf\Amqp\RpcClient;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$rpcClient = ApplicationContext::getContainer()->get(RpcClient::class);
|
||||
// 在 DynamicRpcMessage 上設定與 Consumer 一致的 Exchange 和 RoutingKey
|
||||
|
@ -237,7 +237,7 @@ namespace Hyperf\Utils;
|
||||
|
||||
use App\Kernel\Context\Coroutine as Co;
|
||||
use Swoole\Coroutine as SwooleCoroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
/**
|
||||
* @method static void defer(callable $callable)
|
||||
|
@ -463,7 +463,7 @@ class OtherConsumerProcess extends ConsumerProcess
|
||||
|
||||
```php
|
||||
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$driver = ApplicationContext::getContainer()->get(DriverFactory::class)->get('other');
|
||||
return $driver->push(new ExampleJob());
|
||||
|
@ -2358,7 +2358,7 @@ return [
|
||||
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Di\Definition\DefinitionSourceFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = new Container((new DefinitionSourceFactory(true))());
|
||||
|
||||
|
@ -463,7 +463,7 @@ $input = new ArrayInput($params);
|
||||
$output = new NullOutput();
|
||||
|
||||
/** @var \Psr\Container\ContainerInterface $container */
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
|
||||
/** @var \Symfony\Component\Console\Application $application */
|
||||
$application = $container->get(\Hyperf\Contract\ApplicationInterface::class);
|
||||
|
@ -17,7 +17,7 @@ composer require hyperf/consul
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -39,7 +39,7 @@ $kv = new KV(function () use ($clientFactory, $consulServer) {
|
||||
```php
|
||||
use Hyperf\Consul\KV;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$clientFactory = $container->get(ClientFactory::class);
|
||||
@ -119,4 +119,4 @@ $response = $kv->get($namespace, ['token' => 'your-token'])->json();
|
||||
- info($sessionId, array $options = []): ConsulResponse
|
||||
- node($node, array $options = []): ConsulResponse
|
||||
- all(array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
- renew($sessionId, array $options = []): ConsulResponse
|
||||
|
@ -235,7 +235,7 @@ try{
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
|
||||
$concurrent = new Concurrent(10);
|
||||
|
||||
|
@ -61,7 +61,7 @@ php bin/hyperf.php vendor:publish hyperf/db
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\DB\DB;
|
||||
|
||||
$db = ApplicationContext::getContainer()->get(DB::class);
|
||||
|
@ -200,7 +200,7 @@ foreach ($books as $book){
|
||||
|
||||
```php
|
||||
use Hyperf\ModelCache\EagerLoad\EagerLoader;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$books = Book::findManyFromCache([1,2,3]);
|
||||
$loader = ApplicationContext::getContainer()->get(EagerLoader::class);
|
||||
|
@ -405,10 +405,10 @@ class IndexController
|
||||
```
|
||||
|
||||
在某些更極端動態的情況下,或者非 `容器(Container)` 的管理作用之下時,想要獲取到 `容器(Container)`
|
||||
物件還可以透過 `\Hyperf\Utils\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 物件。
|
||||
物件還可以透過 `\Hyperf\Context\ApplicationContext::getContaienr()` 方法來獲得 `容器(Container)` 物件。
|
||||
|
||||
```php
|
||||
$container = \Hyperf\Utils\ApplicationContext::getContainer();
|
||||
$container = \Hyperf\Context\ApplicationContext::getContainer();
|
||||
```
|
||||
|
||||
## 掃描介面卡
|
||||
|
@ -24,7 +24,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Etcd\KVInterface;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(KVInterface::class);
|
||||
|
@ -444,7 +444,7 @@ interface CalculatorServiceInterface
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use App\JsonRpc\CalculatorServiceInterface;
|
||||
use App\JsonRpc\MathValue;
|
||||
|
||||
|
@ -133,7 +133,7 @@ $log->alert('czl');
|
||||
namespace App;
|
||||
|
||||
use Hyperf\Logger\LoggerFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
class Log
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ return [
|
||||
use Hyperf\HttpServer\Router\Router;
|
||||
|
||||
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();
|
||||
return $renderer->render($registry->getMetricFamilySamples());
|
||||
});
|
||||
|
@ -242,7 +242,7 @@ class NsqCommand extends HyperfCommand
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Nsq\Nsqd\Topic;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
@ -111,7 +111,7 @@ namespace App\Controller;
|
||||
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Hyperf\RateLimit\Annotation\RateLimit;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
class TestController
|
||||
|
@ -58,7 +58,7 @@ php bin/hyperf.php vendor:publish hyperf/redis
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
@ -140,7 +140,7 @@ $result = $redis->keys('*');
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
@ -98,7 +98,7 @@ return $response->getContent();
|
||||
```php
|
||||
<?php
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
$app = Factory::miniProgram([]);
|
||||
|
@ -71,7 +71,7 @@ return [
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -84,7 +84,7 @@ $id = $generator->generate();
|
||||
```php
|
||||
<?php
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(IdGeneratorInterface::class);
|
||||
@ -126,7 +126,7 @@ class UserDefinedIdGenerator
|
||||
}
|
||||
}
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$container = ApplicationContext::getContainer();
|
||||
$generator = $container->get(UserDefinedIdGenerator::class);
|
||||
|
@ -152,7 +152,7 @@ function onSomeEvent(\Hyperf\SocketIOServer\Socket $socket){
|
||||
|
||||
```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
|
||||
// 向 game 房間內的所有連線推送 bigger-announcement 事件。
|
||||
|
@ -46,7 +46,7 @@ Task 元件提供了 `主動方法投遞` 和 `註解投遞` 兩種使用方法
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\TaskExecutor;
|
||||
use Hyperf\Task\Task;
|
||||
|
||||
@ -76,7 +76,7 @@ $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id(
|
||||
<?php
|
||||
|
||||
use Hyperf\Utils\Coroutine;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Task\Annotation\Task;
|
||||
|
||||
class AnnotationTask
|
||||
@ -178,7 +178,7 @@ class MongoTask
|
||||
```php
|
||||
<?php
|
||||
use App\Task\MongoTask;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
$client = ApplicationContext::getContainer()->get(MongoTask::class);
|
||||
$client->insert('hyperf.test', ['id' => rand(0, 99999999)]);
|
||||
|
@ -231,7 +231,7 @@ class UserTest extends HttpTestCase
|
||||
{
|
||||
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);
|
||||
|
||||
@ -392,7 +392,7 @@ namespace HyperfTest\Cases;
|
||||
use App\Api\DemoApi;
|
||||
use App\Logic\DemoLogic;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use HyperfTest\HttpTestCase;
|
||||
use Mockery;
|
||||
|
||||
|
@ -20,9 +20,9 @@ use Hyperf\Amqp\Message\ConsumerMessageInterface;
|
||||
use Hyperf\Amqp\Message\MessageInterface;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
|
||||
use Hyperf\Process\ProcessManager;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use PhpAmqpLib\Channel\AMQPChannel;
|
||||
use PhpAmqpLib\Exception\AMQPTimeoutException;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
@ -14,7 +14,7 @@ namespace Hyperf\Amqp\Message;
|
||||
use Hyperf\Amqp\Builder\QueueBuilder;
|
||||
use Hyperf\Amqp\Packer\Packer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use PhpAmqpLib\Channel\AMQPChannel;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
@ -13,7 +13,7 @@ namespace Hyperf\Amqp\Message;
|
||||
|
||||
use Hyperf\Amqp\Constants;
|
||||
use Hyperf\Amqp\Packer\Packer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
abstract class ProducerMessage extends Message implements ProducerMessageInterface
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Hyperf\Amqp\Message;
|
||||
|
||||
use Hyperf\Amqp\Builder\QueueBuilder;
|
||||
use Hyperf\Amqp\Packer\Packer;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
abstract class RpcMessage extends Message implements RpcMessageInterface
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace HyperfTest\Amqp;
|
||||
|
||||
use Hyperf\Amqp\ConnectionFactory;
|
||||
use Hyperf\Amqp\Consumer;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\Utils\Exception\ChannelClosedException;
|
||||
use Hyperf\Utils\Reflection\ClassInvoker;
|
||||
use HyperfTest\Amqp\Stub\AMQPConnectionStub;
|
||||
|
@ -16,12 +16,12 @@ use Hyperf\Amqp\Consumer;
|
||||
use Hyperf\Amqp\IO\IOFactory;
|
||||
use Hyperf\Amqp\Pool\PoolFactory;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\ExceptionHandler\Formatter\DefaultFormatter;
|
||||
use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Mockery;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\AsyncQueue;
|
||||
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\CompressInterface;
|
||||
use Hyperf\Contract\UnCompressInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
|
||||
class AnnotationJob extends Job
|
||||
{
|
||||
|
@ -20,8 +20,8 @@ use Hyperf\AsyncQueue\MessageInterface;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Contract\PackerInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\Process\ProcessManager;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -17,12 +17,12 @@ use Hyperf\AsyncQueue\Aspect\AsyncQueueAspect;
|
||||
use Hyperf\AsyncQueue\Driver\DriverFactory;
|
||||
use Hyperf\AsyncQueue\Driver\DriverInterface;
|
||||
use Hyperf\AsyncQueue\Environment;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
use Hyperf\Di\Annotation\Aspect;
|
||||
use Hyperf\Di\Aop\Ast;
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use HyperfTest\AsyncQueue\Stub\FooProxy;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
@ -12,10 +12,10 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\AsyncQueue;
|
||||
|
||||
use Hyperf\AsyncQueue\Driver\ChannelConfig;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\AsyncQueue\Stub\Redis;
|
||||
use HyperfTest\AsyncQueue\Stub\RedisDriverStub;
|
||||
|
@ -15,10 +15,10 @@ use Hyperf\AsyncQueue\Driver\ChannelConfig;
|
||||
use Hyperf\AsyncQueue\Driver\RedisDriver;
|
||||
use Hyperf\AsyncQueue\JobMessage;
|
||||
use Hyperf\AsyncQueue\Message;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Hyperf\Utils\Str;
|
||||
use HyperfTest\AsyncQueue\Stub\DemoJob;
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace HyperfTest\AsyncQueue\Stub;
|
||||
|
||||
use Hyperf\AsyncQueue\Driver\RedisDriver;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Hyperf\Coroutine\Concurrent;
|
||||
|
||||
class RedisDriverStub extends RedisDriver
|
||||
{
|
||||
|
@ -14,9 +14,9 @@ namespace HyperfTest\Cache\Cases;
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\FileSystemDriver;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Filesystem\Filesystem;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\Cache\Stub\Foo;
|
||||
|
2
src/cache/tests/Cases/RedisDriverTest.php
vendored
2
src/cache/tests/Cases/RedisDriverTest.php
vendored
@ -16,6 +16,7 @@ use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\KeyCollectorInterface;
|
||||
use Hyperf\Cache\Driver\RedisDriver;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
@ -28,7 +29,6 @@ use Hyperf\Redis\Pool\RedisPool;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use HyperfTest\Cache\Stub\Foo;
|
||||
use HyperfTest\Cache\Stub\SerializeRedisDriver;
|
||||
|
2
src/cache/tests/Stub/ContainerStub.php
vendored
2
src/cache/tests/Stub/ContainerStub.php
vendored
@ -14,6 +14,7 @@ namespace HyperfTest\Cache\Stub;
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\RedisDriver;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Di\Container;
|
||||
@ -26,7 +27,6 @@ use Hyperf\Redis\Pool\RedisPool;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Redis\RedisFactory;
|
||||
use Hyperf\Redis\RedisProxy;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Packer\PhpSerializerPacker;
|
||||
use Mockery;
|
||||
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace Hyperf\Command;
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace HyperfTest\Command;
|
||||
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Utils\Reflection\ClassInvoker;
|
||||
use HyperfTest\Command\Command\DefaultSwooleFlagsCommand;
|
||||
use HyperfTest\Command\Command\FooCommand;
|
||||
|
@ -14,9 +14,9 @@ namespace HyperfTest\ConfigApollo;
|
||||
use Hyperf\Config\Config;
|
||||
use Hyperf\ConfigApollo\Client;
|
||||
use Hyperf\ConfigApollo\Option;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Guzzle\ClientFactory;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user