Local Classic + PHPUnit + PhpStorm

My need wasn’t for PHP unit, but searching if it was possible to connect with SSH to container. And how to do it with security (adding this possibility only for a user with a specific password …)
As I read this tutorial carefully, I have followed Step1 and Step2 and I wonder… Isn’t it dangerous to install OpenSSH-server in a Local By Flywheel container and give the ability to connect to container with root / root ? Anyone discover your Remote Host and Port can connect with SSH and then break everything… isn’t it?
… …
Finally, I tried an SSH connection with an external PC to the one containing LBFW and the result is a connection timed out! So, everything is OK!!! :blush:

I’m also getting the provisioning forever bug (OSX 10.14.3, Local 3.0.4). Is the ports add-on still being maintained?

Just had to do this again in 2019. My working process was:

  1. Download and run this script in my local environment: https://gist.github.com/keesiemeijer/a888f3d9609478b310c2d952644891ba
  2. Follow the steps above, but skip step 3
1 Like

I just ran into this exact same issue today. The only way I was able to fix it was by completely creating a new site and starting over :confused:

Current process:

  1. Set up ports as detailed in step 1 above
  2. open site SSH and run this script: https://gist.github.com/alexstandiford/0728ba7b21caa323a5ecf67c6e98abd2
  3. Restart local
  4. Open site SSH and run this script:
    https://gist.github.com/keesiemeijer/a888f3d9609478b310c2d952644891ba
  5. Start on step 4 - Configure PHPStorm above.

The Ports extension is deprecated, and I don’t see any way to add ports in Local Lightning. Is there any way to use PHPUnit and PhpStorm with Local Lightning?

Sorry I can’t help you get setup with PhpStorm, but the above should help.

Thanks, @afragen, but the part of the process I need help with is setting up 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