- Notifications
You must be signed in to change notification settings - Fork 368
[Docs] Add xdebug testing page #2840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
25 commits Select commit Hold shift + click to select a range
6695c75 Adding first draft
fellyph 47d218c make it more concise
fellyph ee69b5d Merge branch 'trunk' of https://github.com/WordPress/wordpress-playgr…
fellyph efe1be5 adding IDE integration flag
fellyph 267bd14 removing duplicated content
fellyph 3b24718 applying wordpress docs check
fellyph 3c6d8da Merge branch 'trunk' of https://github.com/WordPress/wordpress-playgr…
fellyph 0281651 adding more demos about using xdebug
fellyph 6338552 adding comparison between php cli and playground cli
fellyph d0c9b87 removing long guide and breakdown on smaller pages
fellyph ce1e46b adding intro page and getting started
fellyph 599d47e adding demos
fellyph aac7966 updating getting started
fellyph 3f81593 Merge branch 'trunk' of https://github.com/WordPress/wordpress-playgr…
fellyph fa28e91 updating getting started page
fellyph ee97cce revert changes
fellyph 49d5c39 Adding french version
fellyph 3218c6d Updating VS code section
fellyph c622e58 updating getting started guide
fellyph 7535ce8 updating translations
fellyph c48a44f Merge branch 'trunk' into add-xdebug-wasm-test-page
fellyph 7e06dee Refine IDE integration details in Xdebug documentation
fellyph a1a3246 Improve clarity and grammar in Xdebug guide
fellyph 5b52a62 Improve Xdebug getting started documentation
fellyph 9a1e24d Enhance Xdebug IDE integration instructions
fellyph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions 42 packages/docs/site/docs/developers/07-xdebug/01-introduction.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| title: Using Xdebug with PHP WASM - Introduction | ||
| slug: /developers/xdebug/introduction | ||
| description: Debug PHP code running in WebAssembly within WordPress Playground using Xdebug, Chrome DevTools, and IDE integration. | ||
| --- | ||
| | ||
| # Using Xdebug with PHP WASM | ||
| | ||
| Xdebug is a debugging extension for PHP that lets you set breakpoints, inspect variables, and step through your code. WordPress Playground includes Xdebug in its WebAssembly-compiled PHP, so you can debug WordPress code running directly in your browser or IDE. | ||
| | ||
| ## Why Xdebug matters for PHP WASM | ||
| | ||
| Debugging PHP code in WebAssembly is different from debugging traditional PHP. Without Xdebug, you're limited to `var_dump()` and `error_log()` statements. Xdebug gives you a proper debugger with breakpoints, variable inspection, and call stack navigation—the same tools you'd use when debugging PHP on a regular server. | ||
| | ||
| ## XDebug on WordPress Playground | ||
| | ||
| For a quick start, check the [getting started with Xdebug guide](/developers/xdebug/getting-started) | ||
| | ||
| You'll learn to debug: | ||
| | ||
| - Form processing logic | ||
| - Input validation | ||
| - WordPress hooks and filters | ||
| | ||
| ## Two debugging approaches | ||
| | ||
| WordPress Playground supports two ways to debug with Xdebug: | ||
| | ||
| **Chrome DevTools**: Debug directly in your browser without any IDE setup. Great for quick debugging sessions or when you want to see everything in one place. | ||
| | ||
| **IDE integration**: Use VSCode or PhpStorm with full IDE features like code navigation, project-wide search, and advanced breakpoint conditions. Better for complex debugging scenarios. | ||
| | ||
| Both methods work with the same Xdebug setup. You can even use them simultaneously. Choose what works best for your workflow. | ||
| | ||
| ## What you'll need | ||
| | ||
| - Node.js installed | ||
| - Chrome or Chromium browser (for DevTools debugging) | ||
| - Visual Studio Code or PhpStorm (for IDE debugging, optional) | ||
| - Basic familiarity with WordPress plugin development | ||
| | ||
| **Next**: [Getting Started with Xdebug →](/developers/xdebug/getting-started) | ||
118 changes: 118 additions & 0 deletions 118 packages/docs/site/docs/developers/07-xdebug/02-getting-started.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| --- | ||
| title: Getting Started with Xdebug | ||
| slug: /developers/xdebug/getting-started | ||
| description: Before you can start debugging, you need to run WordPress Playground with Xdebug enabled. This guide covers the basics. | ||
| --- | ||
| | ||
| # Getting Started with Xdebug | ||
| | ||
| This guide shows you how to enable Xdebug in WordPress Playground and start debugging your code. | ||
| | ||
| ## PHP WASM CLI vs Playground CLI | ||
| | ||
| First, Xdebug is present in two different CLIs: | ||
| | ||
| - **`@php-wasm/cli`**: Run standalone PHP scripts. Use this when debugging PHP code without needing a WordPress environment. | ||
| - **`@wp-playground/cli`**: Run a full WordPress installation. Useful for debugging WordPress plugins, themes, or core functionality. | ||
| | ||
| For this guide, we'll use `@wp-playground/cli`. If you're not familiar with the tool, we recommend reading the [`@wp-playground/cli` guide](/developers/local-development/wp-playground-cli), but the same process can also be applied to debugging PHP applications with `@php-wasm/cli`. | ||
| | ||
| ## Quick start with `npx` | ||
| | ||
| The fastest way to get started is using npx, which doesn't require installation: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug | ||
| ``` | ||
| | ||
| This starts WordPress on `http://127.0.0.1:9400` with Xdebug enabled. Now you connect a debugger. | ||
| | ||
| ## Starting with DevTools | ||
| | ||
| To debug with Chrome DevTools, add the `--experimental-devtools` flag: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-devtools | ||
| ``` | ||
| | ||
| The terminal will display a URL to connect Chrome DevTools: | ||
| | ||
| ```bash | ||
| Starting a PHP server... | ||
| Setting up WordPress latest | ||
| Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip | ||
| Fetching SQLite integration plugin... | ||
| Booting WordPress... | ||
| WordPress is running on http://127.0.0.1:9400 with 1 worker(s) | ||
| Starting XDebug Bridge... | ||
| Connect Chrome DevTools to CDP at: | ||
| devtools://devtools/bundled/inspector.html?ws=localhost:9229 | ||
| | ||
| Chrome connected! Initializing Xdebug receiver... | ||
| XDebug receiver running on port 9003 | ||
| Running a PHP script with Xdebug enabled... | ||
| ``` | ||
| | ||
| By clicking on the provided URL, for example, `devtools://devtools/bundled/inspector.html?ws=localhost:9229`, you can access DevTools connected to your application, with the ability to inspect all files of a WordPress instance. | ||
| | ||
|  | ||
| | ||
| For a more practical example, let's debug a plugin that has the following code: | ||
| | ||
| ```PHP | ||
| <?php | ||
| /** | ||
| * Plugin Name: Simple Admin Message | ||
| * Description: Displays a simple message in the WordPress admin | ||
| * Version: 1.0 | ||
| * Author: Playground Team | ||
| */ | ||
| | ||
| // Prevent direct access | ||
| if (!defined('ABSPATH')) { | ||
| exit; | ||
| } | ||
| | ||
| // Display admin notice | ||
| function sam_display_admin_message() { | ||
| $message = 'Hello! This is a simple admin message.'; | ||
| ?> | ||
| <div class="notice notice-info is-dismissible"> | ||
| <p><?php _e($message, 'simple-admin-message'); ?></p> | ||
| </div> | ||
| <?php | ||
| } | ||
| add_action('admin_notices', 'sam_display_admin_message'); | ||
| ``` | ||
| | ||
| In the folder where the plugin is located, let's run the command in our terminal: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-devtools --auto-mount | ||
| ``` | ||
| | ||
| The Playground CLI(`@wp-playground/cli`) will automatically detect the plugin folder and mount it. Opening the project in your browser and DevTools, you'll be able to add breakpoints in your plugin's code and test it line by line. | ||
| | ||
|  | ||
| | ||
| ## Starting with IDE integration | ||
| | ||
| Similar to the process with DevTools, let's use the same plugin code from before to debug with VSCode, add the `--experimental-unsafe-ide-integration=vscode` flag. This flag will optimize the setup process for VSCode. If you're working with PhpStorm, just add the `--experimental-unsafe-ide-integration=phpstorm` flag. | ||
| | ||
| To debug in VSCode you'll need the following prerequisites: | ||
| | ||
| 1. An extension to add PHP profiling support, for example, [PHP Profiler](https://open-vsx.org/extension/devsense/profiler-php-vscode) | ||
fellyph marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| 2. A `.vscode/` folder. If the `launch.json` file doesn't exist, don't worry, `@wp-playground/cli` will create it. | ||
fellyph marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| 3. Enable breakpoints in your IDE. Some IDEs come with this feature disabled, so pay attention to this detail. | ||
| | ||
| If everything is ready, you run the command: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-unsafe-ide-integration=vscode --auto-mount | ||
| ``` | ||
| | ||
| Now, go to your code, add the breakpoints and happy testing. | ||
| | ||
|  | ||
| | ||
| This feature is in experimental mode. Until it is completed, we will need your feedback. Please connect with us in the [#playground Slack channel](https://wordpress.slack.com/archives/C04EWKGDJ0K) and share your thoughts. | ||
42 changes: 42 additions & 0 deletions 42 .../docusaurus-plugin-content-docs/current/developers/07-xdebug/01-introduction.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| title: Usando Xdebug con PHP WASM - Introducción | ||
| slug: /developers/xdebug/introduction | ||
| description: Depura código PHP ejecutándose en WebAssembly dentro de WordPress Playground usando Xdebug, Chrome DevTools e integración con IDE. | ||
| --- | ||
| | ||
| # Usando Xdebug con PHP WASM | ||
| | ||
| Xdebug es una extensión de depuración para PHP que te permite establecer puntos de interrupción, inspeccionar variables y recorrer tu código paso a paso. WordPress Playground incluye Xdebug en su PHP compilado para WebAssembly, por lo que puedes depurar código de WordPress que se ejecuta directamente en tu navegador o IDE. | ||
| | ||
| ## Por qué Xdebug es importante para PHP WASM | ||
| | ||
| Depurar código PHP en WebAssembly es diferente de depurar PHP tradicional. Sin Xdebug, estás limitado a declaraciones `var_dump()` y `error_log()`. Xdebug te ofrece un depurador adecuado con puntos de interrupción, inspección de variables y navegación de la pila de llamadas: las mismas herramientas que usarías al depurar PHP en un servidor regular. | ||
| | ||
| ## XDebug en WordPress Playground | ||
| | ||
| Para un inicio rápido, consulta la [guía de primeros pasos con Xdebug](/developers/xdebug/getting-started) | ||
| | ||
| Aprenderás a depurar: | ||
| | ||
| - Lógica de procesamiento de formularios | ||
| - Validación de entrada | ||
| - Hooks y filtros de WordPress | ||
| | ||
| ## Dos enfoques de depuración | ||
| | ||
| WordPress Playground admite dos formas de depurar con Xdebug: | ||
| | ||
| **Chrome DevTools**: Depura directamente en tu navegador sin configuración de IDE. Excelente para sesiones rápidas de depuración o cuando quieres ver todo en un solo lugar. | ||
| | ||
| **Integración con IDE**: Usa VSCode o PhpStorm con funciones completas de IDE como navegación de código, búsqueda en todo el proyecto y condiciones avanzadas de puntos de interrupción. Mejor para escenarios de depuración complejos. | ||
| | ||
| Ambos métodos funcionan con la misma configuración de Xdebug. Incluso puedes usarlos simultáneamente. Elige lo que mejor se adapte a tu flujo de trabajo. | ||
| | ||
| ## Lo que necesitarás | ||
| | ||
| - Node.js instalado | ||
| - Navegador Chrome o Chromium (para depuración con DevTools) | ||
| - Visual Studio Code o PhpStorm (para depuración con IDE, opcional) | ||
| - Conocimiento básico de desarrollo de plugins de WordPress | ||
| | ||
| **Siguiente**: [Primeros Pasos con Xdebug →](/developers/xdebug/getting-started) |
160 changes: 160 additions & 0 deletions 160 ...cusaurus-plugin-content-docs/current/developers/07-xdebug/02-getting-started.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| --- | ||
| title: Primeros Pasos con Xdebug | ||
| slug: /developers/xdebug/getting-started | ||
| description: Antes de comenzar a depurar, necesitas ejecutar WordPress Playground con Xdebug habilitado. Esta guía cubre lo básico. | ||
| --- | ||
| | ||
| <!-- # Getting Started with Xdebug --> | ||
| | ||
| # Primeros Pasos con Xdebug | ||
| | ||
| <!-- This guide shows you how to enable Xdebug in WordPress Playground and start debugging your code. --> | ||
| | ||
| Esta guía te muestra cómo habilitar Xdebug en WordPress Playground y comenzar a depurar tu código. | ||
| | ||
| <!-- ## PHP WASM CLI vs Playground CLI --> | ||
| | ||
| ## PHP WASM CLI vs Playground CLI | ||
| | ||
| <!-- First, Xdebug is present in two different CLIs: --> | ||
| | ||
| Primero, Xdebug está presente en dos CLI diferentes: | ||
| | ||
| - **`@php-wasm/cli`**: Ejecuta scripts PHP independientes. Úsalo cuando estés depurando código PHP sin necesidad de un entorno WordPress. | ||
| - **`@wp-playground/cli`**: Ejecuta una instalación completa de WordPress. Útil para depurar plugins de WordPress, temas o funcionalidades del núcleo. | ||
| | ||
| <!-- For this guide, we'll use `@wp-playground/cli`. If you're not familiar with the tool, we recommend reading the [`@wp-playground/cli` guide](/developers/local-development/wp-playground-cli), but the same process can also be applied to debugging PHP applications with `@php-wasm/cli`. --> | ||
| | ||
| Para esta guía, utilizaremos `@wp-playground/cli`. Si no estás familiarizado con la herramienta, recomendamos leer la guía de [`@wp-playground/cli`](/developers/local-development/wp-playground-cli), pero el mismo proceso también puede aplicarse a la depuración de aplicaciones PHP con `@php-wasm/cli`. | ||
| | ||
| <!-- ## Quick start with `npx` --> | ||
| | ||
| ## Inicio rápido con `npx` | ||
| | ||
| <!-- The fastest way to get started is using npx, which doesn't require installation: --> | ||
| | ||
| La forma más rápida de comenzar es usar npx, que no requiere instalación: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug | ||
| ``` | ||
| | ||
| <!-- This starts WordPress on `http://127.0.0.1:9400` with Xdebug enabled. Now you connect a debugger. --> | ||
| | ||
| Esto inicia WordPress en `http://127.0.0.1:9400` con Xdebug habilitado. Ahora conectas un depurador. | ||
| | ||
| <!-- ## Starting with DevTools --> | ||
| | ||
| ## Iniciando con DevTools | ||
| | ||
| <!-- To debug with Chrome DevTools, add the `--experimental-devtools` flag: --> | ||
| | ||
| Para depurar con Chrome DevTools, agrega la bandera `--experimental-devtools`: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-devtools | ||
| ``` | ||
| | ||
| <!-- The terminal will display a URL to connect Chrome DevTools: --> | ||
| | ||
| La terminal mostrará una URL para conectar Chrome DevTools: | ||
| | ||
| ```bash | ||
| Starting a PHP server... | ||
| Setting up WordPress latest | ||
| Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip | ||
| Fetching SQLite integration plugin... | ||
| Booting WordPress... | ||
| WordPress is running on http://127.0.0.1:9400 with 1 worker(s) | ||
| Starting XDebug Bridge... | ||
| Connect Chrome DevTools to CDP at: | ||
| devtools://devtools/bundled/inspector.html?ws=localhost:9229 | ||
| | ||
| Chrome connected! Initializing Xdebug receiver... | ||
| XDebug receiver running on port 9003 | ||
| Running a PHP script with Xdebug enabled... | ||
| ``` | ||
| | ||
| <!-- By clicking on the provided URL, for example, `devtools://devtools/bundled/inspector.html?ws=localhost:9229`, you can access DevTools connected to your application, with the ability to inspect all files of a WordPress instance. --> | ||
| | ||
| Al hacer clic en la URL proporcionada, por ejemplo, `devtools://devtools/bundled/inspector.html?ws=localhost:9229`, puedes acceder a DevTools conectado con tu aplicación, con la posibilidad de inspeccionar todos los archivos de una instancia WordPress. | ||
| | ||
|  | ||
| | ||
| <!-- For a more practical example, let's debug a plugin that has the following code: --> | ||
| | ||
| Para un ejemplo más práctico, vamos a depurar un plugin que tiene el siguiente código: | ||
| | ||
| ```PHP | ||
| <?php | ||
| /** | ||
| * Plugin Name: Simple Admin Message | ||
| * Description: Displays a simple message in the WordPress admin | ||
| * Version: 1.0 | ||
| * Author: Playground Team | ||
| */ | ||
| | ||
| // Prevent direct access | ||
| if (!defined('ABSPATH')) { | ||
| exit; | ||
| } | ||
| | ||
| // Display admin notice | ||
| function sam_display_admin_message() { | ||
| $message = 'Hello! This is a simple admin message.'; | ||
| ?> | ||
| <div class="notice notice-info is-dismissible"> | ||
| <p><?php _e($message, 'simple-admin-message'); ?></p> | ||
| </div> | ||
| <?php | ||
| } | ||
| add_action('admin_notices', 'sam_display_admin_message'); | ||
| ``` | ||
| | ||
| <!-- In the folder where the plugin is located, let's run the command in our terminal: --> | ||
| | ||
| En la carpeta donde se encuentra el plugin, ejecutemos el comando en nuestro terminal: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-devtools --auto-mount | ||
| ``` | ||
| | ||
| <!-- The Playground CLI(`@wp-playground/cli`) will automatically detect the plugin folder and mount it. Opening the project in your browser and DevTools, you'll be able to add breakpoints in your plugin's code and test it line by line. --> | ||
| | ||
| El Playground CLI (`@wp-playground/cli`) detectará automáticamente la carpeta del plugin y la montará. Abriendo el proyecto en tu navegador y DevTools, podrás agregar breakpoints en el código de tu plugin y probarlo línea por línea. | ||
| | ||
|  | ||
| | ||
| <!-- ## Starting with IDE integration --> | ||
| | ||
| ## Iniciando con integración IDE | ||
| | ||
| <!-- Similar to the process with DevTools, let's use the same plugin code from before to debug with VSCode, add the `--experimental-unsafe-ide-integration=vscode` flag. This flag will optimize the setup process for VSCode. If you're working with PhpStorm, just add the `--experimental-unsafe-ide-integration=phpstorm` flag. --> | ||
| | ||
| Similar al proceso con DevTools, vamos a utilizar el mismo código del plugin anterior para depurar con VSCode, agrega la bandera `--experimental-unsafe-ide-integration=vscode`. Esta bandera optimizará el proceso de configuración para VSCode. Si trabajas con PhpStorm, simplemente agrega la bandera `--experimental-unsafe-ide-integration=phpstorm`. | ||
| | ||
| <!-- To debug in VSCode you'll need the following prerequisites: --> | ||
| | ||
| Para depurar en VSCode necesitarás los siguientes prerrequisitos: | ||
| | ||
| 1. Una extensión para agregar soporte de PHP profiling, por ejemplo, [PHP Profiler](https://open-vsx.org/extension/devsense/profiler-php-vscode) | ||
| 2. Una carpeta `.vscode/`. Si el archivo `launch.json` no existe, no te preocupes, `@wp-playground/cli` lo creará. | ||
| 3. Habilita los puntos de interrupción (breakpoints) en tu IDE. Algunos IDEs vienen con esta característica desactivada, así que presta atención a este detalle. | ||
| | ||
| <!-- If everything is ready, you run the command: --> | ||
| | ||
| Si todo está listo, ejecuta el comando: | ||
| | ||
| ```bash | ||
| npx @wp-playground/cli@latest server --xdebug --experimental-unsafe-ide-integration=vscode --auto-mount | ||
| ``` | ||
| | ||
| <!-- Now, go to your code, add the breakpoints and happy testing. --> | ||
| | ||
| Ahora, ve a tu código, agrega los breakpoints y buenas pruebas. | ||
| | ||
|  | ||
| | ||
| <!-- This feature is in experimental mode. Until it is completed, we will need your feedback. Please connect with us in the [#playground Slack channel](https://wordpress.slack.com/archives/C04EWKGDJ0K) and share your thoughts. --> | ||
| | ||
| Esta característica está en modo experimental. Hasta que se complete, necesitaremos tu retroalimentación. Por favor, conéctate con nosotros en el [canal Slack #playground](https://wordpress.slack.com/archives/C04EWKGDJ0K) y comparte tus pensamientos. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.