From 2112c4c5513a6a3c01b27f608001f06b9a17b101 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:37:35 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E6=A0=87=E9=A2=98=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=B9=B6=E6=B7=BB=E5=8A=A0=E4=BD=BF=E7=94=A8=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh_CN/components/cache.md | 6 +-- zh_CN/components/command-signals.md | 5 --- zh_CN/components/compoships.md | 4 +- zh_CN/components/confd.md | 5 --- zh_CN/components/console-spinner.md | 6 --- zh_CN/components/exception-event.md | 32 +++++++++++++ zh_CN/components/facade.md | 2 +- zh_CN/components/helpers.md | 33 ++++++++++++++ zh_CN/components/macros.md | 69 +++++++++++++++++++++++++++++ 9 files changed, 140 insertions(+), 22 deletions(-) diff --git a/zh_CN/components/cache.md b/zh_CN/components/cache.md index 50451da..fec52e1 100644 --- a/zh_CN/components/cache.md +++ b/zh_CN/components/cache.md @@ -8,7 +8,7 @@ composer require friendsofhyperf/cache ## 用法 -- 注解 +### 注解 ```php namespace App\Controller; @@ -31,7 +31,7 @@ class IndexController } ``` -- 门面 +### 门面 ```php use FriendsOfHyperf\Cache\Facade\Cache; @@ -41,7 +41,7 @@ Cache::remember($key, $ttl=60, function() { }); ``` -- 切换驱动 +### 切换驱动 ```php use FriendsOfHyperf\Cache\Facade\Cache; diff --git a/zh_CN/components/command-signals.md b/zh_CN/components/command-signals.md index a7ad59f..eb11468 100644 --- a/zh_CN/components/command-signals.md +++ b/zh_CN/components/command-signals.md @@ -2,11 +2,6 @@ The signals component for Hyperf Command. -## 依赖 - -- PHP >= 8.0 -- Hyperf >= 3.1 - ## 安装 ```shell diff --git a/zh_CN/components/compoships.md b/zh_CN/components/compoships.md index d209d58..2e8c5ed 100644 --- a/zh_CN/components/compoships.md +++ b/zh_CN/components/compoships.md @@ -2,7 +2,7 @@ **Compoships** 提供了在 Hyperf 的 Model ORM 中基于两个(或更多)列指定关系的能力。当处理第三方或预先存在的模式/数据库时,通常会出现需要在 Eloquent 关系的定义中匹配多个列的情况。 -## The problem +## 问题 Eloquent 不支持复合键。因此,无法通过匹配多个列来定义从一个模型到另一个模型的关系。尝试使用 `where` 子句(如下例所示)在预加载关系时不起作用,因为在处理关系时 **$this->team_id** 为 null。 @@ -23,7 +23,7 @@ class User extends Model ## 安装 -推荐的安装 **Compoships** 的方法是通过 [Composer](http://getcomposer.org/) +推荐通过 [Composer](http://getcomposer.org/) 安装 **Compoships** 组件。 ```shell composer require friendsofhyperf/compoships diff --git a/zh_CN/components/confd.md b/zh_CN/components/confd.md index 89d3d7f..f17457a 100644 --- a/zh_CN/components/confd.md +++ b/zh_CN/components/confd.md @@ -2,11 +2,6 @@ The confd component for Hyperf. -## 依赖 - -- PHP >= 8.0 -- Hyperf >= 3.0 - ## 安装 ```shell diff --git a/zh_CN/components/console-spinner.md b/zh_CN/components/console-spinner.md index ecce391..a4cc166 100644 --- a/zh_CN/components/console-spinner.md +++ b/zh_CN/components/console-spinner.md @@ -21,11 +21,6 @@ class FooCommand extends Command { use Spinnerable; - /** - * Execute the console command. - * - * @return void - */ public function handle() { $spinner = $this->spinner($users->count()); @@ -34,7 +29,6 @@ class FooCommand extends Command foreach ($users as $user) { // Do your stuff... - $spinner->advance(); } diff --git a/zh_CN/components/exception-event.md b/zh_CN/components/exception-event.md index 5a0d073..efab0d2 100644 --- a/zh_CN/components/exception-event.md +++ b/zh_CN/components/exception-event.md @@ -5,3 +5,35 @@ ```shell composer require friendsofhyperf/exception-event ``` + +## 使用 + +### 定义监听器 + +```php +getException(); + $message = sprintf('Exception: %s in %s:%s', $exception->getMessage(), $exception->getFile(), $exception->getLine()); + $event->getLogger()->error($message); + } +} +``` diff --git a/zh_CN/components/facade.md b/zh_CN/components/facade.md index 43fd05e..3cc1d9c 100644 --- a/zh_CN/components/facade.md +++ b/zh_CN/components/facade.md @@ -9,7 +9,7 @@ composer require friendsofhyperf/facade ## 支持组件 - [x] AMQP -- [x] App +- [x] App (DI alias) - [x] AsyncQueue - [x] Cache - [x] Config diff --git a/zh_CN/components/helpers.md b/zh_CN/components/helpers.md index 94f7844..e36a392 100644 --- a/zh_CN/components/helpers.md +++ b/zh_CN/components/helpers.md @@ -6,3 +6,36 @@ composer require friendsofhyperf/helpers ``` +## 支持函数 + +- app +- base_path +- blank +- cache +- cookie +- class_namespace +- di +- dispatch +- environment +- enum_value +- event +- filled +- fluent +- info +- literal +- logger +- logs +- now +- object_get +- preg_replace_array +- resolve +- request +- response +- session +- today +- throw_if +- throw_unless +- transform +- validator +- when +- get_client_ip diff --git a/zh_CN/components/macros.md b/zh_CN/components/macros.md index ad95c40..0cea4ff 100644 --- a/zh_CN/components/macros.md +++ b/zh_CN/components/macros.md @@ -6,3 +6,72 @@ composer require friendsofhyperf/macros ``` +## 支持方法 + +### Hyperf\Collection\Arr + +- `Arr::sortByMany` + +### Hyperf\Collection\Collection + +- `Collection::isSingle` +- `Collection::collapseWithKeys` + +### Hyperf\Collection\LazyCollection + +- `LazyCollection::collapseWithKeys` + +### Hyperf\HttpServer\Request + +- `Request::allFiles` +- `Request::anyFilled` +- `Request::boolean` +- `Request::collect` +- `Request::date` +- `Request::except` +- `Request::fake` +- `Request::filled` +- `Request::hasAny` +- `Request::isEmptyString` +- `Request::isNotFilled` +- `Request::keys` +- `Request::host` +- `Request::getHost` +- `Request::httpHost` +- `Request::getHttpHost` +- `Request::getPort` +- `Request::getPsrRequest` +- `Request::getScheme` +- `Request::isSecure` +- `Request::getSchemeAndHttpHost` +- `Request::schemeAndHttpHost` +- `Request::merge` +- `Request::mergeIfMissing` +- `Request::missing` +- `Request::only` +- `Request::wantsJson` +- `Request::whenFilled` +- `Request::whenHas` +- `Request::isJson` +- `Request::enum` +- `Request::exists` +- `Request::str` +- `Request::string` +- `Request::integer` + +### Hyperf\Stringable\Str + +- `Str::createUuidsUsing` +- `Str::createUuidsNormally` +- `Str::deduplicate` +- `Str::markdown` +- `Str::inlineMarkdown` +- `Str::transliterate` + +### Hyperf\Stringable\Stringable + +- `Stringable::deduplicate` +- `Stringable::markdown` +- `Stringable::inlineMarkdown` +- `Stringable::toHtmlString` +- `Stringable::whenIsAscii`