• Skip to main content
  • Skip to primary sidebar

Victor Font Consulting Group, LLC

The DEX Intranet Specialists

  • Home
  • Care Plans
    • Care Articles
    • Optional Subscriptions
  • Consultations
  • Products
    • Code Snippets
    • Public GitHub Repositories
    • Gist Snippets
    • Pastebin Snippets (Free)
    • Free Plugins
  • FAQs
  • Support
    • Graphic Design
  • Contact
    • Speakers
    • Portfolio
  • Resources
    • Free WordPress Video Training
    • Tutorials
    • Articles
    • Cybersecurity
    • EU Referral Network

PHPStorm and XDEBUG Configuration

May 6, 2014 By Victor M. Font Jr.

Contents
  • Xdebug Configuration
  • PHPStorm Configuration
  • Google Chrome
  • Port Forwarding
php
Image Courtesy of http://efffective.com

PHPStorm by JetBrains is considered by many to be one of the best integrated development environments (IDEs) available for PHP. PHP is a server-side scripting language primarily designed for web development, but it is also used as a general-purpose programming language. It's estimated that as of January 2013, PHP was installed on more than 240 million websites and 2.1 million web servers. The very popular WordPress platform is built upon PHP. Originally, the acronym PHP stood for Personal Home Page, but it has since been redefined and now stands for PHP: Hypertext Preprocessor, a recursive backronym.

While PHPStorm is an excellent product and highly recommended, it's documentation falls short. As an author of quite a few books, I may be overly critical of technical documentation. I like simple to understand directions.

Recently, I've been working on a few projects for Blue Olive Strategic Solutions out of Florence, Alabama. Blue Olive is an award–winning advertising agency made up of talented industry professionals with diversified backgrounds and significant expertise in social marketing, logo design, graphic design and website design and development. One of these projects is a home-grown PHP application the agency depends upon for scheduling, task management, and billing. It was written over 7 years ago for a very early version of PHP and has not been maintained since the original developer parted the company. I was asked to bring the application up to current standards and migrate it to a new server. After several weeks and over 1,000 changes, I had the application working well on my MacBook Pro, which I use for development. Of course, when I moved all of the source code to the new server, it doesn't work and I found that I had to setup my PHPStorm to work with XDEBUG on the remote server. It took me a day and much trial and error before I got everything working, so I thought I'd share what I learned.

There is a lot of information on the web about getting PHPStorm to work with XDEBUG in your local environment, but when it comes to a remote server, the documentation and available tutorials are lacking. In fact, many of the tutorials I looked at call “localhost" a remote server, which it is not. The remote server I'm working with is a Virtual Private Server (VPS) setup in the Amazon cloud. It is running Ubuntu 14.04 LTS. If you're running a different Linux distribution, these instructions may or may not work for you. All I can say, is try. You have nothing to lose.

Xdebug Configuration

The first thing we're going to do is setup the Xdebug configuration. The Xdebug configuration is either inside php.ini or in another ini file often called xdebug.ini. On the Ubuntu server, the xdebug.ini file is found in the /etc/php5/mods-available directory. There is also a symbolic link to this file in the /etc/php5/apache2/conf.d directory. The contents of the xdebug.ini file are:

After making these changes, restart Apache. In Ubuntu, the command is “service apache2 restart."

PHPStorm Configuration

The most important thing to do with PHPStorm is to make sure the Debug port is set to the same port you designated in your Xdegug.ini file. To set the PHPStorm Xdebug port, go to the preferences file and select PHP/Debug, then follow the example as in the image below:

PHPStorm Debug

Google Chrome

I've found that PHPStorm works best with Chrome when debugging. Chrome needs the Xdebug helper extension to connect to Xdebug for PHP and the JetBrains IDE Support extension to connect to PHPStorm for HTML and JavaScript. Both of those are pretty straight forward to setup. The only configuration needed is to set the session ID for Xdebug Helper to PHPStorm.

Xdebug Helper Config

Note: PHPStorm can only connect to one port for Xdebug. This means that every time we change a site from the default port, the IDE needs to be reconfigured.

Port Forwarding

In order for the Xdebug connection to reach your development box, you need to make certain the Xdebug port is forwarded from your router to your development machine. Each router is different and you should consult your router's documentation to determine exactly how to forward ports. As a representative example, my router is an ASUS RT-AC66R. The following screen print demonstrates how port forwarding works in my setup.

ASUS RT-AC66 Port Forwarding

Note: Port forwarding only works if you assign a static IP address to your development machine.

  • 8shares
  • Facebook0
  • Twitter0
  • Pinterest0
  • LinkedIn8
  • Print
  • SMS0

Filed Under: Code Snippet, Computers and Internet, How To, PHP, Programming, Tutorial Tagged With: Code Snippet, Computers and Internet, How To, PHP, Programming, Tutorial

About Victor M. Font Jr.

Victor M. Font Jr. is an award winning author, entrepreneur, and Senior IT Executive. A Founding Board Member of the North Carolina Executive Roundtable, he has served on the Board of Advisors, of the North Carolina Technology Association, the International Institute of Business Analysis, Association of Information Technology Professionals, Toastmasters International, and the North Carolina Commission for Mental Health, Developmental Disabilities, and Substance Abuse Services. He is author of several books including The Ultimate Guide to the SDLC and Winning With WordPress Basics, and Cybersecurity.

Primary Sidebar

Shopping Cart

Books

  • Winning With WordPress Basics 2nd Edition Winning With WordPress Basics 2nd Edition $19.95
  • Ultimate Guide to the SDLC front cover The Ultimate Guide to the SDLC
    Rated 5.00 out of 5
    $74.95

Recent Articles

  • Modern Scam Defense: How Consumers and Businesses Can Recognize and Stop Email, Phone, and Text Fraud
  • How to Write a PRD So Dense It’s Technically a Novel
  • Top 5 Plugin Names That Scare Our Legal Department
  • When Agile Meets Our 3-Year Waterfall Roadmap: A Love Story
  • Why Our Enterprise Needs 27 Stakeholders to Approve a Button Color Change

Top 10 Article Categories

Best Practice Code Snippet Computers and Internet Genesis How To Leadership Programming Servant Leadership Tutorial WordPress

 
We only use analytical cookies on our website that allow us to recognize and count the number of visitors, but they do not identify you individually. They help us to improve the way our website works. By clicking Accept you, agree to cookies being used in accordance with our Cookie Policy.