diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 260d076c3a..c8f35ff678 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -299,7 +299,7 @@ The steps assume the following environment: 4. Debug Go files from CLion - - Right click on a *.go file in the Project view on the left + - Right click on a \*.go file in the Project view on the left - Override file type → C/C++ Now you can place breakpoints in C, C++ and Go files. @@ -348,7 +348,7 @@ Use GoLand for primary Go development, but the debugger cannot debug C code. To debug C files from GoLand -- Right click on a *.c file in the Project view on the left +- Right click on a \*.c file in the Project view on the left - Override file type → Go Now you can place breakpoints in C, C++ and Go files. diff --git a/docs/cn/extension-workers.md b/docs/cn/extension-workers.md index 2c2d0c645a..98cef730ef 100644 --- a/docs/cn/extension-workers.md +++ b/docs/cn/extension-workers.md @@ -135,12 +135,12 @@ while (frankenphp_handle_request($handler)) { FrankenPHP 提供了钩子,用于在生命周期的特定点执行 Go 代码。 -| 钩子类型 | 选项名称 | 签名 | 上下文与用例 | -| :------- | :--------------------------- | :----------------------- | :--------------------------------------------------- | -| **服务器** | `WithWorkerOnServerStartup` | `func()` | 全局设置。**只运行一次**。示例:连接到 NATS/Redis。 | -| **服务器** | `WithWorkerOnServerShutdown` | `func()` | 全局清理。**只运行一次**。示例:关闭共享连接。 | -| **线程** | `WithWorkerOnReady` | `func(threadID int)` | 每线程设置。在线程启动时调用。接收线程 ID。 | -| **线程** | `WithWorkerOnShutdown` | `func(threadID int)` | 每线程清理。接收线程 ID。 | +| 钩子类型 | 选项名称 | 签名 | 上下文与用例 | +| :--------- | :--------------------------- | :------------------- | :-------------------------------------------------- | +| **服务器** | `WithWorkerOnServerStartup` | `func()` | 全局设置。**只运行一次**。示例:连接到 NATS/Redis。 | +| **服务器** | `WithWorkerOnServerShutdown` | `func()` | 全局清理。**只运行一次**。示例:关闭共享连接。 | +| **线程** | `WithWorkerOnReady` | `func(threadID int)` | 每线程设置。在线程启动时调用。接收线程 ID。 | +| **线程** | `WithWorkerOnShutdown` | `func(threadID int)` | 每线程清理。接收线程 ID。 | ### 示例 diff --git a/docs/cn/hot-reload.md b/docs/cn/hot-reload.md index e83a6e5f36..ffca766dbe 100644 --- a/docs/cn/hot-reload.md +++ b/docs/cn/hot-reload.md @@ -25,7 +25,7 @@ FrankenPHP 包含一个内置的**热重载**功能,旨在极大改善开发 > > 此功能仅适用于**开发环境**。 > 请勿在生产环境中启用 `hot_reload`,因为此功能不安全(会暴露敏感的内部细节)并且会降低应用程序的速度。 -> + ```caddyfile localhost @@ -145,5 +145,5 @@ php_server { 4. **接收**:浏览器通过 JavaScript 库监听,接收 Mercure 事件。 5. **更新**: - - 如果检测到 **Idiomorph**,它会获取更新的内容并修改当前的 HTML 以匹配新状态,即时应用更改而不会丢失状态。 - - 否则,将调用 `window.location.reload()` 来刷新页面。 + - 如果检测到 **Idiomorph**,它会获取更新的内容并修改当前的 HTML 以匹配新状态,即时应用更改而不会丢失状态。 + - 否则,将调用 `window.location.reload()` 来刷新页面。 diff --git a/docs/cn/worker.md b/docs/cn/worker.md index 33a040bbac..f39dd4a9f1 100644 --- a/docs/cn/worker.md +++ b/docs/cn/worker.md @@ -184,3 +184,4 @@ $handler = static function () use ($workerServer) { }; // ... +``` diff --git a/docs/es/classic.md b/docs/es/classic.md index 1176723ac3..c597141c62 100644 --- a/docs/es/classic.md +++ b/docs/es/classic.md @@ -3,9 +3,9 @@ Sin ninguna configuración adicional, FrankenPHP opera en modo clásico. En este modo, FrankenPHP funciona como un servidor PHP tradicional, sirviendo directamente archivos PHP. Esto lo convierte en un reemplazo directo para PHP-FPM o Apache con mod_php. Al igual que Caddy, FrankenPHP acepta un número ilimitado de conexiones y utiliza un [número fijo de hilos](config.md#caddyfile-config) para atenderlas. La cantidad de conexiones aceptadas y en cola está limitada únicamente por los recursos disponibles del sistema. -El *pool* de hilos de PHP opera con un número fijo de hilos inicializados al inicio, comparable al modo estático de PHP-FPM. También es posible permitir que los hilos [escale automáticamente en tiempo de ejecución](performance.md#max_threads), similar al modo dinámico de PHP-FPM. +El _pool_ de hilos de PHP opera con un número fijo de hilos inicializados al inicio, comparable al modo estático de PHP-FPM. También es posible permitir que los hilos [escale automáticamente en tiempo de ejecución](performance.md#max_threads), similar al modo dinámico de PHP-FPM. Las conexiones en cola esperarán indefinidamente hasta que un hilo de PHP esté disponible para atenderlas. Para evitar esto, puedes usar la configuración `max_wait_time` en la [configuración global de FrankenPHP](config.md#caddyfile-config) para limitar la duración que una petición puede esperar por un hilo de PHP libre antes de ser rechazada. Adicionalmente, puedes establecer un [tiempo límite de escritura razonable en Caddy](https://caddyserver.com/docs/caddyfile/options#timeouts). -Cada instancia de Caddy iniciará solo un *pool* de hilos de FrankenPHP, el cual será compartido entre todos los bloques `php_server`. +Cada instancia de Caddy iniciará solo un _pool_ de hilos de FrankenPHP, el cual será compartido entre todos los bloques `php_server`. diff --git a/docs/es/compile.md b/docs/es/compile.md index 269b0ff629..540e31ac81 100644 --- a/docs/es/compile.md +++ b/docs/es/compile.md @@ -79,11 +79,11 @@ sudo make install Algunas características de FrankenPHP dependen de dependencias opcionales del sistema que deben instalarse. Alternativamente, estas características pueden deshabilitarse pasando etiquetas de compilación al compilador Go. -| Característica | Dependencia | Etiqueta de compilación para deshabilitarla | -| ----------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | -| Compresión Brotli | [Brotli](https://github.com/google/brotli) | nobrotli | -| Reiniciar workers al cambiar archivos | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher | -| [Mercure](mercure.md) | [Biblioteca Mercure Go](https://pkg.go.dev/github.com/dunglas/mercure) (instalada automáticamente, licencia AGPL) | nomercure | +| Característica | Dependencia | Etiqueta de compilación para deshabilitarla | +| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | +| Compresión Brotli | [Brotli](https://github.com/google/brotli) | nobrotli | +| Reiniciar workers al cambiar archivos | [Watcher C](https://github.com/e-dant/watcher/tree/release/watcher-c) | nowatcher | +| [Mercure](mercure.md) | [Biblioteca Mercure Go](https://pkg.go.dev/github.com/dunglas/mercure) (instalada automáticamente, licencia AGPL) | nomercure | ## Compilar la aplicación Go diff --git a/docs/es/embed.md b/docs/es/embed.md index fa324609b4..5841ce3414 100644 --- a/docs/es/embed.md +++ b/docs/es/embed.md @@ -66,7 +66,7 @@ La forma más fácil de crear un binario para Linux es usar el constructor basad RUN EMBED=dist/app/ ./build-static.sh ``` - > [!CAUTION] + > [!CAUTION] > > Algunos archivos `.dockerignore` (por ejemplo, el [`.dockerignore` predeterminado de Symfony Docker](https://github.com/dunglas/symfony-docker/blob/main/.dockerignore)) > ignorarán el directorio `vendor/` y los archivos `.env`. Asegúrese de ajustar o eliminar el archivo `.dockerignore` antes de la construcción. diff --git a/docs/es/extension-workers.md b/docs/es/extension-workers.md index fa7eecfc40..656917b25e 100644 --- a/docs/es/extension-workers.md +++ b/docs/es/extension-workers.md @@ -135,12 +135,12 @@ while (frankenphp_handle_request($handler)) { FrankenPHP proporciona hooks para ejecutar código Go en puntos específicos del ciclo de vida. -| Tipo de Hook | Nombre de Opción | Firma | Contexto y Caso de Uso | -| :----------- | :--------------------------- | :------------------- | :-------------------------------------------------------------------------- | -| **Server** | `WithWorkerOnServerStartup` | `func()` | Configuración global. Se ejecuta **Una vez**. Ejemplo: Conectar a NATS/Redis. | +| Tipo de Hook | Nombre de Opción | Firma | Contexto y Caso de Uso | +| :----------- | :--------------------------- | :------------------- | :------------------------------------------------------------------------------- | +| **Server** | `WithWorkerOnServerStartup` | `func()` | Configuración global. Se ejecuta **Una vez**. Ejemplo: Conectar a NATS/Redis. | | **Server** | `WithWorkerOnServerShutdown` | `func()` | Limpieza global. Se ejecuta **Una vez**. Ejemplo: Cerrar conexiones compartidas. | -| **Thread** | `WithWorkerOnReady` | `func(threadID int)` | Configuración por hilo. Llamado cuando un hilo inicia. Recibe el ID del hilo. | -| **Thread** | `WithWorkerOnShutdown` | `func(threadID int)` | Limpieza por hilo. Recibe el ID del hilo. | +| **Thread** | `WithWorkerOnReady` | `func(threadID int)` | Configuración por hilo. Llamado cuando un hilo inicia. Recibe el ID del hilo. | +| **Thread** | `WithWorkerOnShutdown` | `func(threadID int)` | Limpieza por hilo. Recibe el ID del hilo. | ### Ejemplo diff --git a/docs/es/extensions.md b/docs/es/extensions.md index da85623a24..cf22542f45 100644 --- a/docs/es/extensions.md +++ b/docs/es/extensions.md @@ -87,21 +87,21 @@ Mientras que el primer punto se explica por sí mismo, el segundo puede ser más Aunque algunos tipos de variables tienen la misma representación en memoria entre C/PHP y Go, algunos tipos requieren más lógica para ser usados directamente. Esta es quizá la parte más difícil cuando se trata de escribir extensiones porque requiere entender los internos del motor Zend y cómo se almacenan las variables internamente en PHP. Esta tabla resume lo que necesitas saber: -| Tipo PHP | Tipo Go | Conversión directa | Helper de C a Go | Helper de Go a C | Soporte para Métodos de Clase | -|---------------------|--------------------------------|---------------------|---------------------------------------|----------------------------------------|-------------------------------| -| `int` | `int64` | ✅ | - | - | ✅ | -| `?int` | `*int64` | ✅ | - | - | ✅ | -| `float` | `float64` | ✅ | - | - | ✅ | -| `?float` | `*float64` | ✅ | - | - | ✅ | -| `bool` | `bool` | ✅ | - | - | ✅ | -| `?bool` | `*bool` | ✅ | - | - | ✅ | -| `string`/`?string` | `*C.zend_string` | ❌ | `frankenphp.GoString()` | `frankenphp.PHPString()` | ✅ | -| `array` | `frankenphp.AssociativeArray` | ❌ | `frankenphp.GoAssociativeArray()` | `frankenphp.PHPAssociativeArray()` | ✅ | -| `array` | `map[string]any` | ❌ | `frankenphp.GoMap()` | `frankenphp.PHPMap()` | ✅ | -| `array` | `[]any` | ❌ | `frankenphp.GoPackedArray()` | `frankenphp.PHPPackedArray()` | ✅ | -| `mixed` | `any` | ❌ | `GoValue()` | `PHPValue()` | ❌ | -| `callable` | `*C.zval` | ❌ | - | frankenphp.CallPHPCallable() | ❌ | -| `object` | `struct` | ❌ | _Aún no implementado_ | _Aún no implementado_ | ❌ | +| Tipo PHP | Tipo Go | Conversión directa | Helper de C a Go | Helper de Go a C | Soporte para Métodos de Clase | +| ------------------ | ----------------------------- | ------------------ | --------------------------------- | ---------------------------------- | ----------------------------- | +| `int` | `int64` | ✅ | - | - | ✅ | +| `?int` | `*int64` | ✅ | - | - | ✅ | +| `float` | `float64` | ✅ | - | - | ✅ | +| `?float` | `*float64` | ✅ | - | - | ✅ | +| `bool` | `bool` | ✅ | - | - | ✅ | +| `?bool` | `*bool` | ✅ | - | - | ✅ | +| `string`/`?string` | `*C.zend_string` | ❌ | `frankenphp.GoString()` | `frankenphp.PHPString()` | ✅ | +| `array` | `frankenphp.AssociativeArray` | ❌ | `frankenphp.GoAssociativeArray()` | `frankenphp.PHPAssociativeArray()` | ✅ | +| `array` | `map[string]any` | ❌ | `frankenphp.GoMap()` | `frankenphp.PHPMap()` | ✅ | +| `array` | `[]any` | ❌ | `frankenphp.GoPackedArray()` | `frankenphp.PHPPackedArray()` | ✅ | +| `mixed` | `any` | ❌ | `GoValue()` | `PHPValue()` | ❌ | +| `callable` | `*C.zval` | ❌ | - | frankenphp.CallPHPCallable() | ❌ | +| `object` | `struct` | ❌ | _Aún no implementado_ | _Aún no implementado_ | ❌ | > [!NOTE] > diff --git a/docs/es/known-issues.md b/docs/es/known-issues.md index bf7e637b0e..e4ce1cf56a 100644 --- a/docs/es/known-issues.md +++ b/docs/es/known-issues.md @@ -4,17 +4,17 @@ Las siguientes extensiones se sabe que no son compatibles con FrankenPHP: -| Nombre | Razón | Alternativas | -| ----------------------------------------------------------------------------------------------------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------- | -| [imap](https://www.php.net/manual/es/imap.installation.php) | No es thread-safe | [javanile/php-imap2](https://github.com/javanile/php-imap2), [webklex/php-imap](https://github.com/Webklex/php-imap) | -| [newrelic](https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/introduction-new-relic-php/) | No es thread-safe | - | +| Nombre | Razón | Alternativas | +| ----------------------------------------------------------------------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------- | +| [imap](https://www.php.net/manual/es/imap.installation.php) | No es thread-safe | [javanile/php-imap2](https://github.com/javanile/php-imap2), [webklex/php-imap](https://github.com/Webklex/php-imap) | +| [newrelic](https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/introduction-new-relic-php/) | No es thread-safe | - | ## Extensiones PHP con Errores Las siguientes extensiones tienen errores conocidos y comportamientos inesperados cuando se usan con FrankenPHP: -| Nombre | Problema | -| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Nombre | Problema | +| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [ext-openssl](https://www.php.net/manual/es/book.openssl.php) | Cuando se usa musl libc, la extensión OpenSSL puede fallar bajo cargas pesadas. El problema no ocurre cuando se usa la más popular GNU libc. Este error está [siendo rastreado por PHP](https://github.com/php/php-src/issues/13648). | ## get_browser diff --git a/docs/es/worker.md b/docs/es/worker.md index a2d49f4439..b841c628d0 100644 --- a/docs/es/worker.md +++ b/docs/es/worker.md @@ -152,7 +152,7 @@ curl -X POST http://localhost:2019/frankenphp/workers/restart ### Fallos en Workers Si un script de worker falla con un código de salida distinto de cero, FrankenPHP lo reiniciará con una estrategia de retroceso exponencial. -Si el script de worker permanece activo más tiempo que el último retroceso * 2, +Si el script de worker permanece activo más tiempo que el último retroceso \* 2, no penalizará al script de worker y lo reiniciará nuevamente. Sin embargo, si el script de worker continúa fallando con un código de salida distinto de cero en un corto período de tiempo (por ejemplo, tener un error tipográfico en un script), FrankenPHP fallará con el error: `too many consecutive failures`. diff --git a/docs/extensions.md b/docs/extensions.md index 2fe78035cb..54f0e3fb8d 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -17,10 +17,10 @@ We'll start with the generator approach as it's the easiest way to get started, ## Using the Extension Generator -FrankenPHP is bundled with a tool that allows you **to create a PHP extension** only using Go. **No need to write C code** or use CGO directly: FrankenPHP also includes a **public types API** to help you write your extensions in Go without having to worry about **the type juggling between PHP/C and Go**. +FrankenPHP is bundled with a tool that lets you **create a PHP extension** using only Go. **No need to write C code** or use CGO directly: FrankenPHP also includes a **public types API** to help you write your extensions in Go without having to worry about **the type juggling between PHP/C and Go**. > [!TIP] -> If you want to understand how extensions can be written in Go from scratch, you can read the manual implementation section below demonstrating how to write a PHP extension in Go without using the generator. +> If you want to understand how extensions can be written in Go from scratch, you can read the manual implementation section below, demonstrating how to write a PHP extension in Go without using the generator. Keep in mind that this tool is **not a full-fledged extension generator**. It is meant to help you write simple extensions in Go, but it does not provide the most advanced features of PHP extensions. If you need to write a more **complex and optimized** extension, you may need to write some C code or use CGO directly. @@ -44,7 +44,7 @@ tar xf php-* ### Writing the Extension -Everything is now setup to write your native function in Go. Create a new file named `stringext.go`. Our first function will take a string as an argument, the number of times to repeat it, a boolean to indicate whether to reverse the string, and return the resulting string. This should look like this: +Everything is now set up to write your native function in Go. Create a new file named `stringext.go`. Our first function will take a string as an argument, the number of times to repeat it, a boolean to indicate whether to reverse the string, and return the resulting string. This should look like this: ```go package example @@ -77,7 +77,7 @@ func repeat_this(s *C.zend_string, count int64, reverse bool) unsafe.Pointer { There are two important things to note here: -- A directive comment `//export_php:function` defines the function signature in PHP. This is how the generator knows how to generate the PHP function with the right parameters and return type; +- A directive comment `//export_php:function` defines the function signature in PHP. This is how the generator knows how to generate the PHP function with the right parameters and return type. - The function must return an `unsafe.Pointer`. FrankenPHP provides an API to help you with type juggling between C and Go. While the first point speaks for itself, the second may be harder to apprehend. Let's take a deeper dive to type juggling later in this guide. @@ -91,6 +91,7 @@ GEN_STUB_SCRIPT=php-src/build/gen_stub.php frankenphp extension-init my_extensio ``` > [!NOTE] +> > Don't forget to set the `GEN_STUB_SCRIPT` environment variable to the path of the `gen_stub.php` file in the PHP sources you downloaded earlier. This is the same `gen_stub.php` script mentioned in the manual implementation section. If everything went well, your project directory should contain the following files for your extension: @@ -104,6 +105,7 @@ If everything went well, your project directory should contain the following fil - **`README.md`** - Documentation > [!IMPORTANT] +> > **Your source file (`my_extension.go`) is never modified.** The generator creates a separate `_generated.go` file containing CGO wrappers that call your original functions. This means you can safely version control your source file without worrying about generated code polluting it. ### Integrating the Generated Extension into FrankenPHP @@ -142,7 +144,7 @@ Once you've integrated your extension into FrankenPHP as demonstrated in the pre ### Type Juggling -While some variable types have the same memory representation between C/PHP and Go, some types require more logic to be directly used. This is maybe the hardest part when it comes to writing extensions because it requires understanding internals of the Zend Engine and how variables are stored internally in PHP. +While some variable types have the same memory representation between C/PHP and Go, some types require more logic to be directly used. This is maybe the hardest part when it comes to writing extensions because it requires understanding the internals of the Zend Engine and how variables are stored internally in PHP. This table summarizes what you need to know: | PHP type | Go type | Direct conversion | C to Go helper | Go to C helper | Class Methods Support | @@ -167,7 +169,7 @@ This table summarizes what you need to know: > > For class methods specifically, primitive types and arrays are currently supported. Objects cannot be used as method parameters or return types yet. -If you refer to the code snippet of the previous section, you can see that helpers are used to convert the first parameter and the return value. The second and third parameter of our `repeat_this()` function don't need to be converted as memory representation of the underlying types are the same for both C and Go. +If you refer to the code snippet of the previous section, you can see that helpers are used to convert the first parameter and the return value. The second and third parameters of our `repeat_this()` function don't need to be converted, as the memory representation of the underlying types is the same for both C and Go. #### Working with Arrays @@ -258,8 +260,8 @@ func process_data_packed(arr *C.zend_array) unsafe.Pointer { - **Ordered key-value pairs** - Option to keep the order of the associative array - **Optimized for multiple cases** - Option to ditch the order for better performance or convert straight to a slice -- **Automatic list detection** - When converting to PHP, automatically detects if array should be a packed list or hashmap -- **Nested Arrays** - Arrays can be nested and will convert all support types automatically (`int64`,`float64`,`string`,`bool`,`nil`,`AssociativeArray`,`map[string]any`,`[]any`) +- **Automatic list detection** - When converting to PHP, automatically detects if the array should be a packed list or a hashmap +- **Nested Arrays** - Arrays can be nested and will convert all support types automatically (`int64`, `float64`, `string`, `bool`, `nil`, `AssociativeArray`, `map[string]any`, `[]any`) - **Objects are not supported** - Currently, only scalar types and arrays can be used as values. Providing an object will result in a `null` value in the PHP array. ##### Available methods: Packed and Associative @@ -471,6 +473,7 @@ const ( ``` > [!NOTE] +> > PHP constants will take the name of the Go constant, thus using upper case letters is recommended. #### Class Constants @@ -498,6 +501,7 @@ const ( ``` > [!NOTE] +> > Just like global constants, the class constants will take the name of the Go constant. Class constants are accessible using the class name scope in PHP: @@ -515,7 +519,7 @@ echo User::ROLE_ADMIN; // "admin" echo Order::STATE_PENDING; // 0 ``` -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. +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 notations (binary, hex, octal) are supported and dumped as is in the PHP stub file. 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: diff --git a/docs/fr/extension-workers.md b/docs/fr/extension-workers.md index 936049c7bc..bfa463a75b 100644 --- a/docs/fr/extension-workers.md +++ b/docs/fr/extension-workers.md @@ -135,12 +135,12 @@ while (frankenphp_handle_request($handler)) { FrankenPHP fournit des hooks pour exécuter du code Go à des points spécifiques du cycle de vie. -| Type de Hook | Nom de l'Option | Signature | Contexte et Cas d'Utilisation | -| :--------- | :--------------------------- | :------------------- | :--------------------------------------------------------------------- | -| **Serveur** | `WithWorkerOnServerStartup` | `func()` | Configuration globale. Exécuté **Une fois**. Exemple : Connexion à NATS/Redis. | -| **Serveur** | `WithWorkerOnServerShutdown` | `func()` | Nettoyage global. Exécuté **Une fois**. Exemple : Fermeture des connexions partagées. | -| **Thread** | `WithWorkerOnReady` | `func(threadID int)` | Configuration par thread. Appelé lorsqu'un thread démarre. Reçoit l'ID du Thread. | -| **Thread** | `WithWorkerOnShutdown` | `func(threadID int)` | Nettoyage par thread. Reçoit l'ID du Thread. | +| Type de Hook | Nom de l'Option | Signature | Contexte et Cas d'Utilisation | +| :----------- | :--------------------------- | :------------------- | :------------------------------------------------------------------------------------ | +| **Serveur** | `WithWorkerOnServerStartup` | `func()` | Configuration globale. Exécuté **Une fois**. Exemple : Connexion à NATS/Redis. | +| **Serveur** | `WithWorkerOnServerShutdown` | `func()` | Nettoyage global. Exécuté **Une fois**. Exemple : Fermeture des connexions partagées. | +| **Thread** | `WithWorkerOnReady` | `func(threadID int)` | Configuration par thread. Appelé lorsqu'un thread démarre. Reçoit l'ID du Thread. | +| **Thread** | `WithWorkerOnShutdown` | `func(threadID int)` | Nettoyage par thread. Reçoit l'ID du Thread. | ### Exemple diff --git a/docs/fr/hot-reload.md b/docs/fr/hot-reload.md index fc26a6541f..cc5e5cd674 100644 --- a/docs/fr/hot-reload.md +++ b/docs/fr/hot-reload.md @@ -57,7 +57,7 @@ php_server { } ``` -Utilisez la forme longue de `hot_reload` pour spécifier le *topic* Mercure à utiliser ainsi que les répertoires ou fichiers à surveiller : +Utilisez la forme longue de `hot_reload` pour spécifier le _topic_ Mercure à utiliser ainsi que les répertoires ou fichiers à surveiller : ```caddyfile localhost @@ -84,7 +84,7 @@ Le serveur détecte les modifications et publie les modifications automatiquemen FrankenPHP expose l'URL du Hub Mercure à utiliser pour s'abonner aux modifications de fichiers via la variable d'environnement `$_SERVER['FRANKENPHP_HOT_RELOAD']`. La bibliothèque JavaScript [frankenphp-hot-reload](https://www.npmjs.com/package/frankenphp-hot-reload) gére la logique côté client. -Pour l'utiliser, ajoutez le code suivant à votre gabarit (*layout*) principal : +Pour l'utiliser, ajoutez le code suivant à votre gabarit (_layout_) principal : ```php @@ -103,12 +103,14 @@ Alternativement, vous pouvez implémenter votre propre logique côté client en ### Conserver les nœuds DOM existants -Dans de rares cas, comme lors de l'utilisation d'outils de développement tels que [la *web debug toolbar* de Symfony](https://github.com/symfony/symfony/pull/62970), +Dans de rares cas, comme lors de l'utilisation d'outils de développement tels que [la _web debug toolbar_ de Symfony](https://github.com/symfony/symfony/pull/62970), vous pouvez souhaiter conserver des nœuds DOM spécifiques. Pour ce faire, ajoutez l'attribut `data-frankenphp-hot-reload-preserve` à l'élément HTML concerné : ```html -
+