Local Community

Local Classic + PHPUnit + PhpStorm

Have you seen the Xdebug + PhpStorm addon?

Click on your Addon icon in the sidebar and install.

Yes, I am using that add-on already. It lets me run Xdebug, but as far as I can tell it does not give me access to unit tests through PHPUnit, because it needs to connect to a database. That’s why I was asking about setting up ports.

1 Like

I run phpunit via the CLI. The script sets up the database, etc. I know it works on a Mac and likely on Un*x. I don’t run phpunit via the IDE so that might make a difference.

@afragen I’m trying to run phpunit in the IDE on Windows, so I’m trying to do something very different from what you have done.

Hi all (@clay included). I’m running Local by Flywheel v3.3.0 on Windows. I’ve created a site in Local by Flywheel, and would now like to use PHPUnit with it. Are the instructions in this post still the preferred way to do so? The only reason I ask is because when the post was created, this qualifier was added:

Note! This is an involved tutorial! We plan on drastically streamlining the PHPUnit experience with Local in future versions.

Thanks.

This depends on the version of Local you are using. Older versions installed the web/db server in a virtual machine (VirtualBox) while newer versions abandoned the virtual machine for installing the server directly on your native OS.

If you are using the latest and greatest then these instructions won’t work, but you could try @afragen’s recommendation above: Local + PHPUnit + PhpStorm. I haven’t personally tried this method yet.

@wpalchemy - Curious if you ever made headway on this?

I’ve just spent a few minutes investigating. From what I see it looks like Local is similar to a normal WAMP stack under the pretty GUI.

You can find the actual application files at a path something like this:

C:\Program Files (x86)\Local

If you drill down into \resources\extraResources\lightning-services you’ll see the a number of folders representing: mariadb, mysql, nginx, php, and mailhog.

You can find MySQL’s binaries somewhere like:

C:\Program Files (x86)\Local\resources\extraResources\lightning-services\mysql-8.0.16+3\bin\win64\bin

I think one could interact with these directly rather than through Local (though I’m sure that isn’t supported :slight_smile: )…If I dive into it more I’ll post a separate thread as I don’t want to hijack this one.

This is a great article and everything worked for me, but I don’t understand how to, after setting up phpunit and phpstorm, then start testing wordpress-develop. I tried deleting everything in the public folder and then checking out wordpress-develop into the public folder, but then i just get a ton of errors. What location would i checkout wordpress-develop into to get it to work with this article? I’m using Local 3.3.0

Thanks!

After spending weeks of trying to get the new version of Local to actually run PHPUnit in PHPStorm, I finally gave up and reverted back to the docker-based version.

It’s super frustrating that there is no apparent way to do this anymore. I get that it’s local…ish, but the script that runs in the “shell” appears to do some fancy things that are necessary for the environment.

I have managed to get PHPUnit running thanks to @afragen but I’ve hit dead-end after dead-end in trying to get PHPUnit to run inside PHPStorm in this environment.

Does anyone have any advice on how to do this? @clay, perhaps?

My current process is still the same as detailed here: Local + PHPUnit + PhpStorm

I was able to get the ports extension to work, but I had to clone it, and run it directly. You can follow the “developing” directions here to get it to work:

I was pleasantly surprised to find it worked perfectly on 3.2.1

A post was split to a new topic: Local Lightning + PHPUnit + PhpStorm