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