Mitchell McKenna - tagged with phpstorm http://mitchmckenna.com/feed en-us http://blogs.law.harvard.edu/tech/rss LifePress mitchellmckenna@gmail.com Code Snippets with PhpStorm Live Templates – Christoph Rumpel http://mitchmckenna.com/post/19005/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4

Christoph Rumpel demos PhpStorm code snippets a.k.a. live templates.

]]>
Thu, 10 Sep 2020 05:08:00 -0400 http://mitchmckenna.com/post/19005/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4/code-snippets-with-phpstorm-live-templates-phpstorm-tips-with-christoph-rumpel-episode-4
PHPStorm: Auto Run PHPUnit On File Save http://mitchmckenna.com/post/15957/phpstorm-auto-run-phpunit-on-file-save

You can setup PHPStorm to run PHPUnit every time you save a unit test. By doing this you get immediate feedback if your unit tests are passing as you write them. And by running PHPUnit only against the current file you’re editing it can run really fast.

To set this up we need to create a File Watcher:

Preferences > File Watchers

Click (+) sign and select custom to open the new file watcher dialog. Add the following settings:

  • Name: PHPUnit
  • File type: PHP
  • Scope: click the to create a new one called tests and use a pattern like file:tests/*.* if tests is the folder all your unit tests are located in and call it tests or something.
  • Program: $PhpExecutable$
  • Arguments: vendor/bin/phpunit --configuration phpunit.xml.dist $FileDirRelativeToProjectRoot$/$FileName$
  • Working directory: $ProjectFileDir$

]]>
Thu, 19 Nov 2015 15:11:00 -0500 http://mitchmckenna.com/post/15957/phpstorm-auto-run-phpunit-on-file-save/phpstorm-auto-run-phpunit-on-file-save
Disable PHPStorm DQL/SQL Warnings http://mitchmckenna.com/post/15331/disable-phpstorm-dqlsql-warnings

I was getting a lot of yellow warnings for DQL/SQL. Turns out DQL isn't supported yet. You can turn off these warning by going to:

Preferences > Language Injections > and uncheck "SQL select/delete/insert..."

]]>
Tue, 07 Apr 2015 20:16:59 -0400 http://mitchmckenna.com/post/15331/disable-phpstorm-dqlsql-warnings/disable-phpstorm-dqlsql-warnings
Setup PHP CodeSniffer in PHPStorm http://mitchmckenna.com/post/15252/setup-php-codesniffer-in-phpstorm

Install PHP Code Sniffer Using Composer Globally:

composer global require "squizlabs/php_codesniffer=*"

Enable PHP Codesniffer:

Preferences > Languages & Frameworks > PHP > Code Sniffer

path: [get this from running 'which phpcs' in the terminal]

Enable PHPStorm to run Code Sniffer in realtime to detect PSR-2 problems:

Preferences > Inspections > PHP > PHP CodeSniffer validation

]]>
Thu, 12 Mar 2015 17:52:28 -0400 http://mitchmckenna.com/post/15252/setup-php-codesniffer-in-phpstorm/setup-php-codesniffer-in-phpstorm
Setting Up PHPUnit in PHPStorm http://mitchmckenna.com/post/15237/setting-up-phpunit-in-phpstorm

This is more so just notes for how I got PHPUnit running in PHPStorm for my project. There's probably a more optimal way to set this up but this works for now.

Tell PHPStorm to Use Composer's Copy of PHPUnit And Set Default Config

Preferences > PHPUnit

Docs: Loading PHPUnit with Composer.

Edit PHPUnit Configuration to use your custom config file

Run > Edit Configurations

Click the plus (+) sign and select PHPUnit.

Docs: Run/Debug Configuration: PHPUnit.

You can now right click (or use the keyboard shortcut) on files or folders and run unit tests.

Note: It may prompt you to setup the PHP Interpreter, open up terminal and type which php to find out where the php version is that your using then paste that in as the interpreter location (related docs).

Results

PHPStorm now tells how much unit test coverage you have beside each file/folder in the navigation tree and a Coverage panel should slide in from the right.

Setup PHPUnit to Run in Vagrant

You might need to run your phpunit inside Vagrant for some reason, follow this guide to do so.

]]>
Wed, 04 Mar 2015 18:57:06 -0500 http://mitchmckenna.com/post/15237/setting-up-phpunit-in-phpstorm/setting-up-phpunit-in-phpstorm
Fix PhpStorm Not Detecting Correct Namespace For New Files http://mitchmckenna.com/post/15195/fix-phpstorm-not-detecting-correct-namespace-for-new-files

Go to Preferences > Directories, click on the folder with the wrong directory, then click the blue "Sources" button above to mark it as a source root, then click the little "P" icon beside it in the right panel and you can put in what the namespace of that folder should start. In the example they mark any files under the "src" folder to start with the namespace "JetBrains\Wordpress\NetworkMarketing".

enter image description here

]]>
Thu, 19 Feb 2015 14:57:00 -0500 http://mitchmckenna.com/post/15195/fix-phpstorm-not-detecting-correct-namespace-for-new-files/fix-phpstorm-not-detecting-correct-namespace-for-new-files
Almost 2 months since I switched over from vim to phpstorm (+IdeaVim), starting to REALLY like http://mitchmckenna.com/post/15168/mitchellmckenna-almost-2-months-since-i-switched-over-from-vim-to-phpstorm-ideavim-starting-to-really-like-it-php-httptcowoo4we89s9

Almost 2 months since I switched over from #vim to #phpstorm (+IdeaVim), starting to REALLY like it #php http://t.co/WOo4wE89S9

]]>
Tue, 10 Feb 2015 16:53:00 -0500 http://mitchmckenna.com/post/15168/mitchellmckenna-almost-2-months-since-i-switched-over-from-vim-to-phpstorm-ideavim-starting-to-really-like-it-php-httptcowoo4we89s9/mitchellmckenna-almost-2-months-since-i-switched-over-from-vim-to-phpstorm-ideavim-starting-to-really-like-it-php-httptcowoo4we89s9