Skip to content

Commit

Permalink
Update En Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Dec 27, 2024
1 parent c34fd98 commit 3dee8ca
Show file tree
Hide file tree
Showing 50 changed files with 496 additions and 374 deletions.
10 changes: 6 additions & 4 deletions en/components/amqp-job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## Introduction

`friendsofhyperf/amqp-job` is an asynchronous job component based on the `hyperf/amqp` component. It supports dispatching jobs to an AMQP service and then consuming the jobs through consumers.
It encapsulates the `hyperf/amqp` component and provides a more convenient way to dispatch and consume jobs.
`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.

## Installation

Expand All @@ -13,7 +12,7 @@ composer require friendsofhyperf/amqp-job

## Usage

### Dispatch Job
### Dispatching Tasks

```php
use FriendsOfHyperf\AmqpJob\Job;
Expand All @@ -38,9 +37,10 @@ class FooJob extends Job
dispatch(new FooJob());
```

### Register Consumer [Optional]
### Registering a Consumer [Optional]

```php

namespace App\Amqp\Consumer;

use FriendsOfHyperf\AmqpJob\JobConsumer;
Expand All @@ -55,4 +55,6 @@ use Hyperf\Amqp\Annotation\Consumer;
)]
class MyConsumer extends JobConsumer
{
//
}
```
12 changes: 10 additions & 2 deletions en/components/cache.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Cache

## Introduction

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

## Installation

```shell
Expand All @@ -8,7 +12,7 @@ composer require friendsofhyperf/cache

## Usage

### Annotation
### Annotations

```php
namespace App\Controller;
Expand Down Expand Up @@ -41,7 +45,7 @@ Cache::remember($key, $ttl=60, function() {
});
```

### Switch Driver
### Switching Drivers

```php
use FriendsOfHyperf\Cache\Facade\Cache;
Expand All @@ -55,3 +59,7 @@ di(CacheManager::class)->store('co')->remember($key, $ttl=60, function() {
// return sth
});
```

## References

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

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

## Installation

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

## Running
## Execution

- `Ctrl + C`

Expand All @@ -62,4 +62,4 @@ $ hyperf foo
$ hyperf foo
Received signal 15, exiting...
[1] 51936 terminated php bin/hyperf.php foo
```
```
5 changes: 3 additions & 2 deletions en/components/command-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Command Validation

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

## Installation

Expand All @@ -27,7 +27,7 @@ class FooCommand extends HyperfCommand
use ValidatesInput;

/**
* The command to execute
* The command line to execute
*/
protected string $name = 'foo:hello {?name : The name of the person to greet.}';

Expand All @@ -50,3 +50,4 @@ class FooCommand extends HyperfCommand
];
}
}
```
30 changes: 15 additions & 15 deletions 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 based on two (or more) columns in Hyperf's Model ORM. The need to match multiple columns in Eloquent relationship definitions often arises when dealing with third-party or pre-existing schemas/databases.
**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.

## Problem
## Issue

Eloquent doesn't support composite keys. Therefore, it's not possible to define a relationship from one model to another by matching multiple columns. Attempting to use a `where` clause (as shown in the example below) won't work with eager loading relationships because **$this->team_id** is null when processing the relationship.
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.

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

## Installation

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

```shell
composer require friendsofhyperf/compoships
```

## Usage

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

Simply make your model class derive from the `FriendsOfHyperf\Compoships\Database\Eloquent\Model` base class. `FriendsOfHyperf\Compoships\Database\Eloquent\Model` extends the `Eloquent` base class without changing its core functionality.
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.

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

If for some reason you can't derive your models from `FriendsOfHyperf\Compoships\Database\Eloquent\Model`, you can use the `FriendsOfHyperf\Compoships\Compoships` trait. Simply use this trait in your models.
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.

**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**
**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**.

### Usage
### How It Works

... Now we can define relationships from model *A* to another model *B* by matching two or more columns (by passing arrays of columns instead of a string).
... 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).

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

We can use the same syntax to define the inverse of the relationship:
We can use the same syntax to define the inverse relationship:

```php
namespace App;
Expand All @@ -81,15 +81,15 @@ class B extends Model

### Example

As an example, let's say we have a task list with categories managed by multiple user teams where:
For example, suppose we have a task list with categories that are 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

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

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

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

```php
namespace App;
Expand Down
10 changes: 5 additions & 5 deletions en/components/confd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Confd

The confd component for Hyperf.
The configuration management component for Hyperf.

## Installation

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

## Commands

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

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

## Define Listener
## Define a 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');
// do something
// Handle changes
}
}
```
Expand All @@ -57,4 +57,4 @@ class ConfigChangedListener implements ListenerInterface

- [x] Etcd
- [x] Nacos
- [ ] Consul
- [ ] Consul
4 changes: 2 additions & 2 deletions en/components/config-consul.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Config Consul

The consul config component for Hyperf.
Consul configuration component for Hyperf.

## Installation

Expand Down Expand Up @@ -33,4 +33,4 @@ return [
],
],
];
```
```
6 changes: 3 additions & 3 deletions en/components/console-spinner.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Console Spinner

The progress bar component For Hyperf.
A progress bar component for the Hyperf framework.

## Installation

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

The `$spinner` is compatible with Symfony ProgressBar, so you can run any method of this class. Alternatively, you can also use the `withSpinner` method by providing an iterable object.
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.

```php
$this->withSpinner(User::all(), function($user) {
// Do your stuff with $user
}, 'Loading...');
```
```
30 changes: 16 additions & 14 deletions en/components/di-plus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DI Plus

The di plus component for Hyperf.
The dependency injection enhancement component for Hyperf.

## Installation

Expand Down Expand Up @@ -36,23 +36,25 @@ class Foo2
{
}
}
```

class Bar
{
}
Support for annotation-based configuration:

```php
<?php
namespace App;

class BarAtFoo1Factory
use Hyperf\Di\Annotation\Inject;

class Foo1
{
public function __invoke()
{
return new Bar();
}
#[Inject]
public Bar $bar;
}

class BarAtFoo2Factory
class Foo2
{
public function __invoke()
{
return new Bar();
}
#[Inject]
public Bar $bar;
}
```
4 changes: 2 additions & 2 deletions en/components/elasticsearch.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Elasticsearch

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

## Installation

Expand All @@ -25,4 +25,4 @@ class Foo
// ...
}
}
```
```
4 changes: 2 additions & 2 deletions en/components/encryption.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encryption

The encryption component for Hyperf.
Hyperf Encryption Component.

## Installation

Expand All @@ -19,4 +19,4 @@ php bin/hyperf.php vendor:publish friendsofhyperf/encryption
```shell
$encryptString = encrypt($string);
$decryptString = decrypt($encryptString);
```
```
4 changes: 2 additions & 2 deletions 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 Listener
### Define a Listener

```php
<?php
Expand Down Expand Up @@ -36,4 +36,4 @@ class ExceptionEventListener implements ListenerInterface
$event->getLogger()->error($message);
}
}
```
```
6 changes: 3 additions & 3 deletions en/components/facade.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ composer require friendsofhyperf/facade
- [x] Redis
- [x] Request
- [x] Response
- [x] Route
- [x] Session
- [x] Storage
- [x] View
- [x] Translator
- [x] Validator
- [x] View
Loading

0 comments on commit 3dee8ca

Please sign in to comment.