Skip to content

Instantly share code, notes, and snippets.

@Greg-Boggs
Last active July 17, 2017 18:01
Show Gist options
  • Select an option

  • Save Greg-Boggs/a2b0c06cf2f9e92216816a51829d0d30 to your computer and use it in GitHub Desktop.

Select an option

Save Greg-Boggs/a2b0c06cf2f9e92216816a51829d0d30 to your computer and use it in GitHub Desktop.
brew install php71 --without-apache --with-fpm
brew install php71-opcache
brew install php71-mcrypt
brew install php71-xdebug
$(brew --prefix gettext)/bin/envsubst < ~/ts_environment/config/php-ts.ini > $(brew --prefix)/etc/php/php71/conf.d/php-ts.ini
brew services start php70

PHP Configuration file including xdebug is here: https://github.com/thinkshout/ts_environment/blob/master/config/php-ts.ini

After install, change xdebug from port 9000 to 9001 in Preferences -> PHP -> Debugger (Unless your Debug port is 9000? :)

here's a setup of PHPStorm for WordPress, Drupal is similar but slightly different.

Enable WordPress Integration in your PhpStorm Project

  • Navigate to Settings | Languages & Frameworks | PHP | WordPress.
  • Check "Enable WordPress Integration".
  • Click "..." and choose your WordPress Installation Path. (It's probably located at ~/Sites/tror/web/wp)

Enable PHP 7 support

  • Navigate to Settings | Languages & Frameworks | PHP.
  • Set PHP language level: 7.
  • Make sure your CLI Interpreter also specifies PHP 7.
  • If not, click the refresh button, or click "..." and find your php executable. (It's probably located at /usr/local/bin/php)

WordPress Code Style

When WordPress integration is enabled, PHPStorm will automatically offer to set WordPress Code Style based on the coding standards. Just click the popup to "set it".

  • If you miss this opportunity, navigate to Settings | Editor | Code Style | PHP.
  • Click Set from... | Predefined Style | WordPress.

Note: you may need to manually set lower case true/false and null in Settings | Editor | Code Style | PHP | Other.

Pro-tip! Press option+command+L any time to reformat the current file. (If you're formatting an entire existing file, please try to remember to commit all the formatting separately from other changes. This makes code review and history browsing much easier.)

PHP Code Sniffer with WordPress Coding Standards

  • Download the latest release of WordPress Coding Standards, or clone the repository anywhere on your machine.
  • Move the "WordPress" and all of the "WordPress-*" subdirectories within this project to /usr/local/etc/php-code-sniffer/Standards.
  • Navigate to Settings | Editor | Inspections | PHP | PHP Code Sniffer Validation.
  • Click the refresh button next to "Coding standard" to make PHPStorm aware of the new standards.
  • Choose "WordPress-Extra".

More Reading/Other Integrations

https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment