Skip to content

Commit

Permalink
docs: improve clarity and consistency in component documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Dec 29, 2024
1 parent 051f31b commit 2355ad5
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 31 deletions.
7 changes: 5 additions & 2 deletions docs/en/components/amqp-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

`friendsofhyperf/amqp-job` is an asynchronous task component built on the `hyperf/amqp` package. It supports distributing tasks to the AMQP service and consuming these tasks through consumers. It encapsulates the `hyperf/amqp` package and provides a more convenient way to distribute and consume tasks.
`friendsofhyperf/amqp-job` is an asynchronous task component based on the `hyperf/amqp` component. It supports dispatching tasks to an AMQP service, which are then consumed by consumers. By encapsulating the `hyperf/amqp` component, it provides a more convenient way to dispatch and consume tasks.

## Installation

Expand Down Expand Up @@ -35,9 +35,10 @@ class FooJob extends Job
}

dispatch(new FooJob());

```

### Registering a Consumer [Optional]
### Registering Consumers [Optional]

```php

Expand All @@ -52,9 +53,11 @@ use Hyperf\Amqp\Annotation\Consumer;
queue: 'hyperf.queue',
name: 'MyConsumer',
nums: 4

)]
class MyConsumer extends JobConsumer
{
//
}

```
4 changes: 2 additions & 2 deletions docs/en/components/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

`friendsofhyperf/cache` is a component based on `hyperf/cache`. It provides additional simplified extension methods.
`friendsofhyperf/cache` is a component based on `hyperf/cache`. It provides more concise extension methods.

## Installation

Expand Down Expand Up @@ -62,4 +62,4 @@ di(CacheManager::class)->store('co')->remember($key, $ttl=60, function() {

## References

Similar to [Laravel-Cache](https://laravel.com/docs/8.x/cache)
Like [Laravel-Cache](https://laravel.com/docs/8.x/cache)
4 changes: 2 additions & 2 deletions docs/en/components/command-signals.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Signals

The signal handling component of Hyperf Command.
Signal handling component for Hyperf Command.

## Installation

Expand Down Expand Up @@ -47,7 +47,7 @@ class FooCommand extends HyperfCommand
}
```

## Execution
## Running

- `Ctrl + C`

Expand Down
2 changes: 1 addition & 1 deletion docs/en/components/command-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Validation

Validation component for Hyperf command-line usage.
A validation component for Hyperf command line.

## Installation

Expand Down
26 changes: 13 additions & 13 deletions docs/en/components/compoships.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Compoships

**Compoships** provides the ability to specify relationships in Hyperf's Model ORM based on two (or more) columns. This is commonly needed when working with third-party or pre-existing schemas/databases where relationships in Eloquent are defined by matching multiple columns.
**Compoships** provides the ability to define relationships based on two (or more) columns in Hyperf's Model ORM. When dealing with third-party or pre-existing schemas/databases, there is often a need to match multiple columns in the definition of Eloquent relationships.

## Issue
## Problem

Eloquent does not support composite keys. As a result, it is not possible to define relationships from one model to another by matching multiple columns. Attempting to use a `where` clause (as shown below) will not work when eager-loading the relationship, because **$this->team_id** is null during relationship processing.
Eloquent does not support composite keys. Therefore, it is not possible to define relationships from one model to another by matching multiple columns. Attempting to use `where` clauses (as shown in the example below) does not work when eager loading relationships because **$this->team_id** is null when handling the relationship.

```php
namespace App;
Expand All @@ -23,7 +23,7 @@ class User extends Model

## Installation

It is recommended to install the **Compoships** package via [Composer](http://getcomposer.org/).
It is recommended to install the **Compoships** component using [Composer](http://getcomposer.org/).

```shell
composer require friendsofhyperf/compoships
Expand All @@ -33,15 +33,15 @@ composer require friendsofhyperf/compoships

### Using the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` Class

Simply extend your model class from the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` base class. `FriendsOfHyperf\Compoships\Database\Eloquent\Model` extends the `Eloquent` base class without altering its core functionality.
Simply have your model classes extend the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` base class. `FriendsOfHyperf\Compoships\Database\Eloquent\Model` extends the `Eloquent` base class without altering its core functionality.

### Using the `FriendsOfHyperf\Compoships\Compoships` Trait

If, for some reason, you cannot extend your model from `FriendsOfHyperf\Compoships\Database\Eloquent\Model`, you can use the `FriendsOfHyperf\Compoships\Compoships` trait. Simply include the trait in your model.
If for some reason you cannot extend `FriendsOfHyperf\Compoships\Database\Eloquent\Model` in your model, you can use the `FriendsOfHyperf\Compoships\Compoships` trait. Simply use this trait in your model.

**Note:** To define multi-column relationships from model *A* to another model *B*, **both models must either extend `FriendsOfHyperf\Compoships\Database\Eloquent\Model` or use the `FriendsOfHyperf\Compoships\Compoships` trait**.
**Note:** To define a multi-column relationship from model *A* to another model *B*, **both models must extend `FriendsOfHyperf\Compoships\Database\Eloquent\Model` or use the `FriendsOfHyperf\Compoships\Compoships` trait**

### How It Works
### Usage

... Now we can define relationships from model *A* to another model *B* by matching two or more columns (by passing an array of columns instead of a string).

Expand Down Expand Up @@ -81,15 +81,15 @@ class B extends Model

### Example

For example, suppose we have a task list with categories that are managed by multiple user teams, where:
As an example, suppose we have a task list with categories, managed by multiple user teams, where:

- A task belongs to a category
- A task is assigned to a team
- A team has many users
- A user belongs to a team
- A user is responsible for tasks in a category
- A user is responsible for a category's tasks

The user responsible for a specific task is the current user in charge of that category within the team.
The user responsible for a specific task is the currently responsible user for that category within the team.

```php
namespace App;
Expand All @@ -107,7 +107,7 @@ class User extends Model
}
```

The same syntax applies to defining the inverse relationship:
The same syntax can be used to define the inverse relationship:

```php
namespace App;
Expand All @@ -123,4 +123,4 @@ class Task extends Model
return $this->belongsTo(User::class, ['team_id', 'category_id'], ['team_id', 'category_id']);
}
}
```
```
8 changes: 4 additions & 4 deletions docs/en/components/confd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Confd

The configuration management component for Hyperf.
Configuration management component for Hyperf.

## Installation

Expand All @@ -13,13 +13,13 @@ composer require friendsofhyperf/nacos

## Commands

Fetch configuration from `etcd/nacos` and update the `.env` file.
Fetch configuration from `etcd/nacos` and update `.env`.

```shell
php bin/hyperf.php confd:env
```

## Define a Listener
## Define Listener

```php
<?php
Expand Down Expand Up @@ -48,7 +48,7 @@ class ConfigChangedListener implements ListenerInterface
public function process(object $event): void
{
$this->logger->warning('[confd] ConfdChanged');
// Handle changes
// do something
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/en/components/console-spinner.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Console Spinner

A progress bar component for the Hyperf framework.
A progress bar component provided for the Hyperf framework.

## Installation

Expand Down Expand Up @@ -37,7 +37,7 @@ class FooCommand extends Command
}
```

The `$spinner` is compatible with Symfony ProgressBar, so you can call any method of that class. Alternatively, you can use the `withSpinner` method by providing an iterable object.
`$spinner` is compatible with Symfony ProgressBar, so you can run any methods from this class. Alternatively, you can use the `withSpinner` method by providing an iterable object.

```php
$this->withSpinner(User::all(), function($user) {
Expand Down
4 changes: 2 additions & 2 deletions docs/en/components/di-plus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DI Plus

The dependency injection enhancement component for Hyperf.
A dependency injection enhancement component for Hyperf.

## Installation

Expand Down Expand Up @@ -38,7 +38,7 @@ class Foo2
}
```

Support for annotation-based configuration:
Supports annotation-based configuration

```php
<?php
Expand Down
2 changes: 1 addition & 1 deletion docs/en/components/elasticsearch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Elasticsearch

A customized Elasticsearch client component for Hyperf.
A client component for Elasticsearch customized for Hyperf.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/en/components/encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ php bin/hyperf.php vendor:publish friendsofhyperf/encryption

## Usage

```shell
```php
$encryptString = encrypt($string);
$decryptString = decrypt($encryptString);
```
2 changes: 1 addition & 1 deletion docs/en/components/exception-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ composer require friendsofhyperf/exception-event

## Usage

### Define a Listener
### Defining a Listener

```php
<?php
Expand Down

0 comments on commit 2355ad5

Please sign in to comment.