-
Notifications
You must be signed in to change notification settings - Fork 5
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
PhpStorm WordPress Integration #25
Comments
Hi! Thanks for reporting this! Yes, you're right: the WP files are only actually available inside the container. But the WordPress integration does not require WP to be under the project root - it can be literally anywhere within the local filesystem. Here is how the features of the PHPStorm + WP integration compare IMHO to what there is already:
As for using xDebug to step through WP itself e.g. to debug a request, yes, that would be very useful. But there were just so many problems with this approach, and using the official Docker image for this is just way, way simpler. I myself have adopted an IMHO cleaner approach based on my philosophy: if I am not working on some code, then I should not debug that code. But I see how it can sometimes be useful, knowing how WordPress is. Perhaps, it could be possible to share the files from the container into a sub-directory of the project, and kill two birds with one stone? I really wouldn't want to go back to mounting the WP files from the host, but another approach alongside the main one wouldn't hurt to cover this case. |
I agree that using the official Docker image has its merits. Can you elaborate what you mean by "share the files from the container into a sub-directory of the project" if not "mounting the WP files from the host". I've also experimented with using the docker image, but having WP core in the project, e.g. as a composer dev dependency, and using that for the integration. But it feels messy treating something as the code used if it in really isn't. I've ended forgetting about this multiple times, messing with core files to debug an issue and wasting plenty of times until remembering that this core isn't the one the container actually runs of. So this feels fragile too. I know this is a tricky one where one would probably end up with a compromise one way or the other, I was just curious about different approaches I might have missed as well as arguments for and against various approaches. |
I mean something that would make it work the other way. Which should be quite possible, since WP is installed at runtime via the entrypoint, and if you mount that directory from the host, it should get filled up with WP files on our host machine. Or something similar.
I don't think it's necessary to choose. It shouldn't be that hard to change this specific part of the setup to tailor to your needs. And if the approach to that is documented somewhere here, then perhaps it's a viable option for many other people too. |
Oh, that sounds like an interesting idea. See, that is why bouncing ideas is great! 😀 I can imagine one might also run into permission issues with that, but I'll definitely try it. I'll report back. |
I'm much more afraid of cross-mounting issues, which cannot just be remedied by
Thank you! |
Okay so I just tried this in a basic proof of concept.
This installs WP and puts the files in the host filesystem. But since the folder didn't exist it is owned by root which sucks on the host. So I created an empty folder So I then did set a user.
Now this works and puts WP core on the host filesystem where PhpStorm can find it. Minor issue: For changing the WP version one needs to manually empty the |
Okay I went further, now mounting the plugin into WP too.
But now another problem arises, being that we now have nested mounts, which causes a stray root-owned folder being created in Again, this can be worked around by creating |
Ok this is what I've settled with for now. It works for me but I am not sure it is clean enough to be included in a public thing.
What do you think @XedinUnknown ? |
The project includes Does this solve the problem? |
Used https://github.com/XedinUnknown/red-acre-test-a-1 as source. - No more `inc`: source files go into `src` (with some exceptions) - The app is now the main module, and all other modules are optional. - Modules can simply be autoloaded: no need for explicit factory files. - Bootstrap improved, making it more versatile, and usable in tests. - Core WP-related things come from WP context, avoiding needless coupling. - Tools now work on modules too, adding them to QA. - Test base classes for modular layers: test modules alone or together with ease. - Tests improved and added. - Add Node and WP-CLI to relevant virtual services. - Add WordPress directory mapping for easier debugging and more IDE features (#25). - Fix missing `get_plugin_data()` and other WP plugin APIs.
The WP integration of PhpStorm seems to require a local path to WP. But you bake WP into the container which prevents that from working. So you either don't use it or need to have WP core somewhere else on the machine.
Personally I find this useful especially for the hooks integration.
Generally having WP Core hidden in the Container also makes other things difficult like stepping through core with xDebug or working on core itself.
Personally I have often turned to not baking WP into the container for this reason but install it with Composer in the host filesystem and mount it into the container. But this of course comes with other disadvantages like e.g. the usual permission issues with docker mounts.
Curious about your thoughts on this.
The text was updated successfully, but these errors were encountered: