-
Notifications
You must be signed in to change notification settings - Fork 399
add basic IDE setup to docs #1791
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
Open
henderkes
wants to merge
10
commits into
php:main
Choose a base branch
from
static-php:dev-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
82abe1b
add basic IDE setup to docs (WIP)
henderkes 8e51d5d
use windows installed ides
henderkes c0f07a1
remove thingy
henderkes a7c3001
markdown linter
henderkes 7a1e10e
markdown linter 2
henderkes a51c7ae
markdown linter 3
henderkes 7b0966d
markdown linter 4
henderkes 54faf79
reword
henderkes 2bdda86
move docs to CONTRIBUTING.md
henderkes 82dbba7
no bare urls
henderkes 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
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ frankenphp.test | |
| caddy/frankenphp/Build | ||
| package/etc/php.ini | ||
| *.log | ||
| compile_flags.txt | ||
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,142 @@ | ||
| # FrankenPHP Development Environment Setup | ||
|
|
||
| --- | ||
|
|
||
| ## For Windows: WSL2 Setup with X11 GUI Support | ||
|
|
||
| 1. Install WSL2: | ||
|
|
||
| ```powershell | ||
| wsl --install | ||
| ``` | ||
| 2. Install a Linux distribution (example: AlmaLinux 10) via e.g. `wsl --install AlmaLinux-10`. | ||
| 3. Install X11 dependencies to run GUI-based IDEs from within WSL2: | ||
|
|
||
| ```bash | ||
| sudo dnf install libXtst libXi libXrender libXrandr libXcursor libXinerama libXcomposite libXdamage libXext libXfixes | ||
| ``` | ||
|
|
||
| --- | ||
henderkes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Initial setup | ||
|
|
||
| Follow the guide on [compiling from sources](compile.md). | ||
| We will assume you installed these things into the following paths: | ||
| - go: `/usr/local/go` | ||
| - cloned `~/php-src` | ||
| - php: `/usr/local/bin/php` | ||
| - cloned `~/frankenphp` | ||
|
|
||
| ## CLion Setup for CGO glue/PHP Source Development | ||
|
|
||
| ### 1. Install CLion | ||
|
|
||
| * Download from: [https://www.jetbrains.com/clion/download/](https://www.jetbrains.com/clion/download/) | ||
| * Extract and install: | ||
|
|
||
| ```bash | ||
| tar -xzf CLion-*.tar.gz | ||
| sudo mv clion-* /opt/clion | ||
| ``` | ||
| * Launch: | ||
|
|
||
| ```bash | ||
| /opt/clion/bin/clion &>/dev/null | ||
| ``` | ||
|
|
||
| ### 2. Open Project in CLion | ||
|
|
||
| * Open CLion → Open → Select the `~/frankenphp` directory | ||
| * Add a build chain: Settings → Build, Execution, Deployment → Custom Build Targets | ||
| * Select any Build Target, under `Build` set up an External Tool (call it e.g. go build) | ||
| * Set up a wrapper script that builds frankenphp for you, called `go_compile_frankenphp.sh` | ||
|
|
||
| ```bash | ||
| export CGO_CFLAGS="-O0 -g $(php-config --includes)" | ||
| export CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" | ||
| go build -tags=nobadger,nomysql,nopgx | ||
| ``` | ||
|
|
||
| * Under Program, select `go_compile_frankenphp.sh` | ||
| * Leave Arguments blank | ||
| * Working Directory: `~/frankenphp/caddy/frankenphp` | ||
|
|
||
| ### 3. Configure Run Targets | ||
|
|
||
| * Go to **Run → Edit Configurations** | ||
| * Create: | ||
|
|
||
| * **frankenphp**: | ||
|
|
||
| * Type: Native Application | ||
| * Target: select the `go build` target you created | ||
| * Executable: `~/frankenphp/caddy/frankenphp/frankenphp` | ||
| * Arguments: the arguments you want to start frankenphp with, e.g. `php-cli test.php` | ||
|
|
||
| ### 4. Debug Go files from CLion | ||
|
|
||
| * 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. | ||
| To get syntax highlighting for imports from php-src, you may need to tell CLion about the include paths. Create a `compile_flags.txt` file in `~/frankenphp` with the following contents: | ||
|
|
||
| ```gcc | ||
| -I/usr/local/include/php | ||
| -I/usr/local/include/php/Zend | ||
| -I/usr/local/include/php/main | ||
| -I/usr/local/include/php/TSRM | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## GoLand Setup for FrankenPHP Development | ||
|
|
||
| Use GoLand for primary Go development, but the debugger cannot debug C code. | ||
|
|
||
| ### 1. Install GoLand | ||
|
|
||
| * Download from: [https://www.jetbrains.com/go/download/](https://www.jetbrains.com/go/download/) | ||
| * Extract and install: | ||
|
|
||
| ```bash | ||
| tar -xzf goland-*.tar.gz | ||
| sudo mv GoLand-* /opt/goland | ||
| ``` | ||
| * Launch: | ||
|
|
||
| ```bash | ||
| /opt/goland/bin/goland &>/dev/null | ||
| ``` | ||
|
|
||
| ### 2. Open in GoLand | ||
|
|
||
| * Launch GoLand → Open → Select the `~/frankenphp` directory | ||
|
|
||
| --- | ||
|
|
||
| ### Go Configuration | ||
|
|
||
| * Select Go Build | ||
| * Name `frankenphp` | ||
| * Run kind: Directory | ||
|
|
||
| * Directory: `~/frankenphp/caddy/frankenphp` | ||
| * Output directory: `~/frankenphp/caddy/frankenphp` | ||
| * Working directory: `~/frankenphp/caddy/frankenphp` | ||
| * Environment (adjust for your $(php-config ...) output): `CGO_CFLAGS=-O0 -g -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib;CGO_LDFLAGS=-lm -lpthread -lsqlite3 -lxml2 -lbrotlienc -lbrotlidec -lbrotlicommon -lwatcher` | ||
| * Go tool arguments: `-tags=nobadger,nomysql,nopgx` | ||
| * Program arguments: e.g. `php-cli -i` | ||
|
|
||
| You can now place breakpoints and debug through Go code when you debug the `frankenphp` configuration, but breakpoints in C code will not work. | ||
|
|
||
| --- | ||
|
|
||
| ## Debugging and Integration Notes | ||
|
|
||
| * Use **CLion** for debugging PHP internals and `cgo` glue code | ||
| * Use **GoLand** for primary Go development and debugging | ||
| * FrankenPHP can be added as a run configuration in CLion for unified C/Go debugging if needed, but syntax highlighting won't work in Go files | ||
|
|
||
| --- | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's AlmaLinux 10? Is it the official recommandation for WSL? If not, maybe we should discuss what's the "official" recommended distribution to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's an "officially recommended distribution". The default (
wsl --install) uses Ubuntu I believe, but AlmaLinux, Debian, OpenSUSE and more are available by default as well.