Skip to content

Commit

Permalink
docs: 更新文档,调整标题格式并添加使用示例
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Nov 29, 2024
1 parent 3107f5e commit 2112c4c
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 22 deletions.
6 changes: 3 additions & 3 deletions zh_CN/components/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ composer require friendsofhyperf/cache

## 用法

- 注解
### 注解

```php
namespace App\Controller;
Expand All @@ -31,7 +31,7 @@ class IndexController
}
```

- 门面
### 门面

```php
use FriendsOfHyperf\Cache\Facade\Cache;
Expand All @@ -41,7 +41,7 @@ Cache::remember($key, $ttl=60, function() {
});
```

- 切换驱动
### 切换驱动

```php
use FriendsOfHyperf\Cache\Facade\Cache;
Expand Down
5 changes: 0 additions & 5 deletions zh_CN/components/command-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

The signals component for Hyperf Command.

## 依赖

- PHP >= 8.0
- Hyperf >= 3.1

## 安装

```shell
Expand Down
4 changes: 2 additions & 2 deletions zh_CN/components/compoships.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Compoships** 提供了在 Hyperf 的 Model ORM 中基于两个(或更多)列指定关系的能力。当处理第三方或预先存在的模式/数据库时,通常会出现需要在 Eloquent 关系的定义中匹配多个列的情况。

## The problem
## 问题

Eloquent 不支持复合键。因此,无法通过匹配多个列来定义从一个模型到另一个模型的关系。尝试使用 `where` 子句(如下例所示)在预加载关系时不起作用,因为在处理关系时 **$this->team_id** 为 null。

Expand All @@ -23,7 +23,7 @@ class User extends Model

## 安装

推荐的安装 **Compoships** 的方法是通过 [Composer](http://getcomposer.org/)
推荐通过 [Composer](http://getcomposer.org/) 安装 **Compoships** 组件。

```shell
composer require friendsofhyperf/compoships
Expand Down
5 changes: 0 additions & 5 deletions zh_CN/components/confd.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

The confd component for Hyperf.

## 依赖

- PHP >= 8.0
- Hyperf >= 3.0

## 安装

```shell
Expand Down
6 changes: 0 additions & 6 deletions zh_CN/components/console-spinner.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ class FooCommand extends Command
{
use Spinnerable;

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$spinner = $this->spinner($users->count());
Expand All @@ -34,7 +29,6 @@ class FooCommand extends Command

foreach ($users as $user) {
// Do your stuff...

$spinner->advance();
}

Expand Down
32 changes: 32 additions & 0 deletions zh_CN/components/exception-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@
```shell
composer require friendsofhyperf/exception-event
```

## 使用

### 定义监听器

```php
<?php

namespace App\Listener;

use FriendsOfHyperf\ExceptionEvent\Event\ExceptionEvent;

class ExceptionEventListener implements ListenerInterface
{
public function listen(): array
{
return [
ExceptionEvent::class,
];
}

/**
* @param ExceptionEvent|object $event
*/
public function process(object $event)
{
$exception = $event->getException();
$message = sprintf('Exception: %s in %s:%s', $exception->getMessage(), $exception->getFile(), $exception->getLine());
$event->getLogger()->error($message);
}
}
```
2 changes: 1 addition & 1 deletion zh_CN/components/facade.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ composer require friendsofhyperf/facade
## 支持组件

- [x] AMQP
- [x] App
- [x] App (DI alias)
- [x] AsyncQueue
- [x] Cache
- [x] Config
Expand Down
33 changes: 33 additions & 0 deletions zh_CN/components/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
69 changes: 69 additions & 0 deletions zh_CN/components/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

0 comments on commit 2112c4c

Please sign in to comment.