From 8564e1eac165ba927b7c286fbc7ab991b6a926e2 Mon Sep 17 00:00:00 2001 From: battye Date: Sat, 17 Dec 2022 03:11:55 +0000 Subject: [PATCH] [ticket/17086] Add Codespaces documentation PHPBB3-17086 --- .vscode/launch.json | 2 +- README.md | 5 +++- phpBB/docs/codespaces.md | 55 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 phpBB/docs/codespaces.md diff --git a/.vscode/launch.json b/.vscode/launch.json index b7b7f9be7d..1de76f0106 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Listen for Xdebug", + "name": "Debug phpBB", "type": "php", "request": "launch", "port": 9003, diff --git a/README.md b/README.md index 8c493fd424..af3fb91de7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ To run an installation from the repo (and not from a pre-built package) on a loc php ../composer.phar install ``` -Alternatively, you can read our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB. +Alternatively, you can read: + +* Our [Vagrant documentation](phpBB/docs/vagrant.md) to find out how to use Vagrant to develop and contribute to phpBB. +* Our [GitHub Codespaces documentation](phpBB/docs/codespaces.md) to learn about phpBB's cloud-based development environment. ## 📓 Documentation diff --git a/phpBB/docs/codespaces.md b/phpBB/docs/codespaces.md new file mode 100644 index 0000000000..cc5231f78d --- /dev/null +++ b/phpBB/docs/codespaces.md @@ -0,0 +1,55 @@ +## Using GitHub Codespaces with phpBB + +phpBB includes support for [Codespaces](https://docs.github.com/en/codespaces), GitHub's cloud-based software development environment. This allows developers and contributors to run and modify phpBB on a consistent environment through a GitHub account without the need to set up a local web server. + +Codespaces is completely web-based and does not require any code to be downloaded locally. + +Features include: + +* Automatic phpBB installation +* Access to [VS Code](https://docs.github.com/en/codespaces/the-githubdev-web-based-editor) through the web browser +* [Xdebug](https://github.com/xdebug/vscode-php-debug) pre-configured to step through the phpBB code and add breakpoints +* Full LAMP stack with database access +* Commit, push and test code entirely online + +## How it works + +### To run phpBB in Codespaces + +* On the GitHub.com website, fork the `phpbb/phpbb` repository. +* Under the `Code` button, click the `Codespaces` tab and then the `+` button to create a new Codespace. +* It may take several minutes to configure and install phpBB on the newly created virtual machine. Once it is ready, a web-based VS Code instance will appear. +* Under the `Ports` tab, click on the local address under port 80 to open the private website for the new phpBB installation. + * By default, the login details for the new phpBB installation are `admin` / `mypassword` + * Port 9003 is also open to allow Xdebug connections. + +### To use the command line + +* Click on the `Terminal` tab at the bottom of VS Code and make sure the `bash` window is selected in the right sidebar. +* The `workspaces/phpbb` directory contains the code from the workspace. +* Run `mysql -h 127.0.0.1 -u phpbb -p` to log into the MySQL database. The password is `phpbb` and the database name is `phpbb`. + * Tip: type `use phpbb;` after logging in to MySQL to switch to the correct database, then queries can be run for the phpBB tables. + +### To debug code + +* Click the `Run and Debug` tab on the left sidebar in VS Code, then click the green play button next to the `Debug phpBB` option. + * Tip: to confirm that Xdebug is working correctly, run `lsof -i :9003` on the command line. It should show that the port is listening for connections. +* In any of the files in the `phpBB/` directory, add a breakpoint by clicking just to the left of a line number in VS Code. Then, access the private website created on port 80 (found under the VS Code `Ports` tab) through the web browser and navigate to the page with a breakpoint. VS Code will automatically pause execution where the breakpoint is hit, and under the `Run and Debug` tab a variable list will be shown. + +### To commit and push code + +* To save a change made using VS Code on Codespaces, click the `Source Control` tab on the left sidebar in VS Code. +* To stage changes or discard changes, right click the file(s) and select the appropriate option. +* Type a commit message and select the `Commit and Push` option. + +**Remember to stop a Codespace once you are finished with it.** GitHub provides all users with a limited number of free core hours per month. A Codespace can be stopped (or deleted) from the main repository page on GitHub.com. + +## Technical information + +All of the Codespaces configuration can be found in the `.devcontainer/` directory. The `devcontainer.json` holds the general environment information and `Dockerfile` contains the commands to set up the LAMP stack which enables phpBB to run. + +`setup.sh` is used to install phpBB from the command line, using pre-determined details from `phpbb-config.yml`. + +Codespaces can run without the configuration inside the `.vscode/` directory, however by including this no manual intervention is required to set the Xdebug IDE code to `VSCode` (inside `settings.json`) and `Debug phpBB` information, such as the path mapping from the Apache webroot to the `phpbb/phpBB` directory (inside `launch.json`). + +This configuration information can be safely modified to change the development environment, followed by `Ctrl+Shift+P` in VS Code and selection of the `Full Rebuild Container` option. \ No newline at end of file