Skip to content

Commit 92abb16

Browse files
docs: add French translation for extensions (#1705)
1 parent 94ac4b4 commit 92abb16

2 files changed

Lines changed: 646 additions & 9 deletions

File tree

docs/extensions.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Keep in mind that this tool is **not a full-fledged extension generator**. It is
2626

2727
### Prerequisites
2828

29-
As covered in the manual implementation section below, you need to [get the PHP sources](https://www.php.net/downloads.php) and create a new Go module.
29+
As covered in the manual implementation section below as well, you need to [get the PHP sources](https://www.php.net/downloads.php) and create a new Go module.
3030

3131
#### Create a New Module and Get PHP Sources
3232

@@ -36,7 +36,7 @@ The first step to writing a PHP extension in Go is to create a new Go module. Yo
3636
go mod init github.com/my-account/my-module
3737
```
3838

39-
Also, you need to [get the PHP sources](https://www.php.net/downloads.php) for the next steps. Once you have them, decompress them into the directory of your choice, not inside your Go module:
39+
The second step is to [get the PHP sources](https://www.php.net/downloads.php) for the next steps. Once you have them, decompress them into the directory of your choice, not inside your Go module:
4040

4141
```console
4242
tar xf php-*
@@ -188,7 +188,7 @@ func (us *UserStruct) UpdateInfo(name *C.zend_string, age *int64, active *bool)
188188
* **PHP `null` becomes Go `nil`** - when PHP passes `null`, your Go function receives a `nil` pointer
189189

190190
> [!WARNING]
191-
> Currently, class methods have the following limitations. **Arrays and objects are not supported** as parameter types or return types. Only primitive types are supported: `string`, `int`, `float`, `bool` and `void` (for return type). **Nullable parameter types are fully supported** for all primitive types (`?string`, `?int`, `?float`, `?bool`).
191+
> Currently, class methods have the following limitations. **Arrays and objects are not supported** as parameter types or return types. Only scalar types are supported: `string`, `int`, `float`, `bool` and `void` (for return type). **Nullable parameter types are fully supported** for all scalar types (`?string`, `?int`, `?float`, `?bool`).
192192
193193
After generating the extension, you will be allowed to use the class and its methods in PHP. Note that you **cannot access properties directly**:
194194

@@ -276,7 +276,7 @@ echo User::ROLE_ADMIN; // "admin"
276276
echo Order::STATE_PENDING; // 0
277277
```
278278

279-
The directive supports various value types including strings, integers, booleans, floats, and iota constants. When using `iota`, the generator automatically assigns sequential values (0, 1, 2, etc.). Global constants become available in your PHP code as global constants, while class constants are scoped to their respective classes. When using integers, different possible notation (binary, hex, octal) are supported and dumped as is in the PHP stub file.
279+
The directive supports various value types including strings, integers, booleans, floats, and iota constants. When using `iota`, the generator automatically assigns sequential values (0, 1, 2, etc.). Global constants become available in your PHP code as global constants, while class constants are scoped to their respective classes using the public visibility. When using integers, different possible notation (binary, hex, octal) are supported and dumped as is in the PHP stub file.
280280

281281
You can use constants just like you are used to in the Go code. For example, let's take the `repeat_this()` function we declared earlier and change the last argument to an integer:
282282

@@ -380,7 +380,7 @@ echo $processor->process('Hello World', StringProcessor::MODE_LOWERCASE); // "h
380380
echo $processor->process('Hello World', StringProcessor::MODE_UPPERCASE); // "HELLO WORLD"
381381
```
382382

383-
Once you've integrated your extension into FrankenPHP (see next section), you can run this test file using `./frankenphp php-server`, and you should see your extension working.
383+
Once you've integrated your extension into FrankenPHP as demonstrated in the previous section, you can run this test file using `./frankenphp php-server`, and you should see your extension working.
384384

385385
## Manual Implementation
386386

@@ -480,9 +480,7 @@ We then define our PHP function as a native language function:
480480
```c
481481
PHP_FUNCTION(go_print)
482482
{
483-
if (zend_parse_parameters_none() == FAILURE) {
484-
RETURN_THROWS();
485-
}
483+
ZEND_PARSE_PARAMETERS_NONE();
486484

487485
go_print_something();
488486
}
@@ -603,7 +601,7 @@ func go_upper(s *C.zend_string) *C.zend_string {
603601
}
604602
```
605603

606-
This approach is much cleaner and safer than manual memory management. FrankenPHP's helper functions handle the conversion between PHP's `zend_string` format and Go strings automatically. The `false` parameter in `PHPString()` indicates that we want to create a new string (not persistent).
604+
This approach is much cleaner and safer than manual memory management. FrankenPHP's helper functions handle the conversion between PHP's `zend_string` format and Go strings automatically. The `false` parameter in `PHPString()` indicates that we want to create a new non-persistent string (freed at the end of the request).
607605

608606
> [!TIP]
609607
> In this example, we don't perform any error handling, but you should always check that pointers are not `nil` and that the data is valid before using it in your Go functions.

0 commit comments

Comments
 (0)