FWIW, I’ve just copy/pasted the line that Local puts into iterm, into my terminal in PHPStorm, and it lets me go from there.
That definitely works, just not through the Run configuration (to run via a hot key, see the phpunit pass/fail results in the PHPStorm UI, etc). Doing TDD by having to flip to the terminal a couple/few times a minute would get pretty annoying.
Came close to setting it up by trying the ‘Docker’ option and selecting the docker-manager within the flywheel app folder, but not able to set up the rest of the PHPUnit configuration yet. Will keep trying and will ping PHPStorm support to see if they have any thoughts!
I would like to point out that this worked for me (installing phpunit this way) vs. using
This script worked great for me! Thanks for writing and sharing it.
As of right now, 2.2.3, I’m no longer able to install what I need via
apt-get. Downloading the latest
phpunit, version 7, using
wget https://phar.phpunit.de/phpunit.phar && chmod +x phpunit.phar && mv phpunit.phar && /usr/local/bin/phpunit installs
phpunit properly but you have to ensure, now with version 7, that you are using PHP 7.1+ in your site settings.
apt-get installation method, e.g.
apt-get install phpunit will not work and
apt-get will hang with the errors:
The following packages have unmet dependencies: php-codecoverage : Depends: libjs-twitter-bootstrap but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Preparing to unpack .../libjs-twitter-bootstrap_2.0.2+dfsg-5_all.deb ... Unpacking libjs-twitter-bootstrap (2.0.2+dfsg-5) ... dpkg: error processing archive /var/cache/apt/archives/libjs-twitter-bootstrap_2.0.2+dfsg-5_all.deb (--unpack): unable to make backup link of `./etc/apache2/conf-available/libjs-twitter-bootstrap.conf' before installing new version: Operation not permitted Errors were encountered while processing: /var/cache/apt/archives/libjs-twitter-bootstrap_2.0.2+dfsg-5_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
I wrote a guide on how to run PHPUnit and PhpStorm with Local 2.3.0+. See Local + PHPUnit + PhpStorm
Could not install packages
No network connection detected
when I run bash setup-phpunit.sh
Did you SSH into the local server before running the script? And were you connected to the internet?
Yes, I did SSH into the local server
The script is pinging the Google’s public DNS server at ip 126.96.36.199 to check for internet conectivity. It could be the DNS server was down.
Check if you can reach it by SSH in to the local server and using this command:
ping -c 3 --linger=5 188.8.131.52 >> /dev/null 2>&1 && echo "Connected" || echo "Not connected"
If it prints “Not connected” it could mean something is blocking access to this ip address (or the DNS server/internet is down).
You could try removing these lines from the script to remove the connectivity check. You’ll get some warnings if it can’t download the necessary packages.
That worked for me but when I try and run
composer phpcs-tests I get a different error.
Command “phpcs-tests” is not defined.
how do I fix this?
Did you run
composer install before running this command?
Yes, I am running these commands in my theme folder.
yes, I did that . I did it in my theme folder
This doesn’t seem to work in Local 2.4.0.
Found this thread: Local + PHPUnit + PhpStorm
But that doesn’t appear to be working either.
@JJJ I’ve removed the connectivity check altogether. It seems the new version doesn’t ship with the
ping command. Download the updated version and run the command again.
@JJJ The latest version (revision 15) should work with the latest Local version 2.4.2. If it still doesn’t work can you report the errors here. Thanks
Works great! Thanks for doing that!
I have updated this script for Local Lightning.
Adding for new feature request site.
Great that there is an updated script, but has anyone been able to run the script of afragen successfully on a windows 10 install? I tried to setup PHPUnit using this script in git bash, but it doesn’t recognize apt-get so the setup script reports errors in line 244 and 247 and stops the script.
I can try ubuntu but that seems to create a separate env, so I don’t know how it interacts with local.
Could use some help with this.