{"id":18916,"date":"2015-12-19T02:01:25","date_gmt":"2015-12-18T16:01:25","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=18916"},"modified":"2016-01-02T08:23:03","modified_gmt":"2016-01-01T22:23:03","slug":"phpstorm-and-xdebug-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpstorm-and-xdebug-primer-tutorial\/","title":{"rendered":"PHPStorm and Xdebug Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/Xdebug\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"PHPStorm and Xdebug Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/Xdebug\/phpstorm_xdebug-84of.jpg\" title=\"PHPStorm and Xdebug Primer Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">PHPStorm and Xdebug Primer Tutorial<\/p><\/div>\n<p>Though with a large variety of scenarios with code, you can debug a piece of code from the command line &#8230; and don&#8217;t get me wrong because sometimes the command line will be the only way &#8230; the experience of debugging is much better if it is combined with work within an IDE.<\/p>\n<p>In this scenario, what about debugging PHP?  We&#8217;ve been trying out PHPStorm, we talked about at <a target=_blank title='PHPStorm IDE Primer Tutorial' href='#pipt'>PHPStorm IDE Primer Tutorial<\/a>, as shown below, overseeing PHP projects and using the Xdebug debugger.<\/p>\n<p>Roughly speaking, what is required here is, via the <a target=_blank title='Xdebog configiration for PHPStorm information from JetBrains' href='https:\/\/www.jetbrains.com\/phpstorm\/help\/configuring-xdebug.html'>Xdebug Configuration<\/a> advice from JetBrains, the inventors of PHPStorm &#8230;<\/p>\n<ul>\n<li>If Xdebug is not installed, an Xdebug install would be required &#8230; and then &#8230;<\/li>\n<li>PHPStorm Preferences -&gt; Languages and Frameworks -&gt; PHP -&gt; &#8220;&#8230;&#8221; Button gives you both &#8230;\n<ol>\n<li>Location of relevant php.ini (which you&#8217;ll probably change) &#8230; and &#8230;<\/li>\n<li>Xdebug (or other debugger) existance status (to tell you if you are getting anywhere)<\/li>\n<\/ol>\n<li>Changes to that php.ini (of above) with, in our case, lots of stops and starts of our local MAMP Apache web server (to see those changes right)<\/li>\n<\/li>\n<\/ul>\n<p>Cutting to the chase what we found could work with our php.ini (after dismantling any pre-existing [zend] section blockages (though we didn&#8217;t have this)) was &#8230;<\/p>\n<p><code><br \/>\n[xdebug]<br \/>\nzend_extension=\"\/Applications\/MAMP\/bin\/php\/php5.4.10\/lib\/php\/extensions\/no-debug-non-zts-20100525\/xdebug.so\"<br \/>\n;zend_extension=\"\/usr\/lib\/php\/extensions\/no-debug-non-zts-20121212\/xdebug.so\"<br \/>\nxdebug.remote_enable=1<br \/>\nxdebug.remote_autostart=1<br \/>\nxdebug.remote_port=9123<br \/>\nxdebug.remote_host=\"127.0.0.1\"<br \/>\nxdebug.remote_handler=\"dbgp\"<br \/>\nxdebug.remote_mode=\"req\"<br \/>\nxdebug.remote_connect_back=0<br \/>\nxdebug.profiler_enable=1<br \/>\nxdebug.profiler_output_dir=\"\/Library\/pgAgent\/Downloads\/ansible-deployment\/tmp\"<br \/>\n<\/code><\/p>\n<p> &#8230; and we have to thank <a target=_blank title='Useful link' href='http:\/\/stackoverflow.com\/questions\/17736304\/enabling-xdebug-remote-debug-makes-apache-server-very-slow'>this link<\/a>, in particular, among many from the Open Source community, which helped &#8230; thanks.  Perhaps the most contentious configuration above is <i>xdebug.remote_autostart=1<\/i> which can cause extreme slowness on occasions &#8230; if that is the way for you you may want to make it <i>xdebug.remote_autostart=0<\/i> to not have the connection between Xdebug and PHP be checked so often.  And the paths shown were specifically suited only here, we hasten to add &#8230; <strike>dough<\/strike> doh!<\/p>\n<p>Other traps for young players could be &#8230;<\/p>\n<ul>\n<li>Start Listening for PHP Debug Connections (Run option) is useful (rather than &#8220;Stop&#8221; &#8230; doh!)<\/li>\n<li>Set some breakpoints<\/li>\n<li>Break at the First Line of Code (Run option) quite useful<\/li>\n<li>The initial connection between PHPStorm and Xdebug may take quite some time, and remember to accept the connection, should a connection window appear<\/li>\n<\/ul>\n<p>Today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/Xdebug\/\" title='Click picture'>slideshow<\/a> offering is <i>warts and all<\/i> as life is when you cannot be sure what happens next?!<\/p>\n<hr>\n<p id='pipt'>Previous relevant <a target=_blank title='PHPStorm IDE Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/phpstorm-ide-primer-tutorial\/'>PHPStorm IDE Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"PHPStorm IDE Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/phpstorm-0of.jpg\" title=\"PHPStorm IDE Primer Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">PHPStorm IDE Primer Tutorial<\/p><\/div>\n<p>Unlike compiled software code, PHP code is often coded simply with the use of a good text editor.   That doesn&#8217;t mean programmers are not looking for a good PHP <a target=_blank rirle='Integrated Development Environment information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Integrated_development_environment'>IDE<\/a> if it comes along.  Today we are going to talk, for the first time at this blog, about a great IDE to use with PHP based projects.  It is called <a target=_blank title='PHPStorm landing page' href='https:\/\/www.jetbrains.com\/phpstorm\/'>PHPStorm<\/a> for good reason, as it is jam packed full of functionality and features, such as &#8230;<\/p>\n<ol>\n<li>PHP Code Editor<\/li>\n<ul>\n<li>PHP 5.3, 5.4, 5.5, 5.6 &#038; 7 support<\/li>\n<li>smart code completion<\/li>\n<li>syntax highlighting<\/li>\n<li>extended code formatting configuration<\/li>\n<li>on-the-fly error checking<\/li>\n<li>code folding<\/li>\n<li>language mixture support<\/li>\n<\/ul>\n<li>Debugging, Testing and Profiling<\/li>\n<ul>\n<li>context-relevant local variables and user-defined watches<\/li>\n<li>edit values on the fly<\/li>\n<li>remote debugging for your server<\/li>\n<li>debug in multiple sessions simultaneously<\/li>\n<li>keep debugging session alive while moving between pages<\/li>\n<\/ul>\n<li>HTML\/CSS\/JavaScript Editor<\/li>\n<ul>\n<li>DOM-based, browser-specific completion<\/li>\n<li>live editing preview<\/li>\n<li>utilize all the power of Emmet (formerly Zen Coding)<\/li>\n<li>JavaScript refactorings available are Rename, Extract Variable\/Function, Inline Variable\/Function, Move\/Copy, Safe Delete, Extract embedded script into file<\/li>\n<li>automatic compilation\/transpilation of modern web development languages to JavaScript (from CoffeeScript, TypeScript, Dart, etc) or CSS (from Sass, SCSS, Less, Stylus, Compass, etc.)<\/li>\n<li>JavaScript debugger<\/li>\n<li>auto-fixes for such problems as: missing required attributes, invalid attributes or illegal values, wrong references to files in links, duplicate attributes, invalid CSS selector format, invalid CSS properties, unused CSS class definitions, invalid local anchors<\/li>\n<li>Angular 2, TSLint, JSLint\/JSHint, Node.js, Flow support<\/li>\n<\/ul>\n<li>Development Environment<\/li>\n<ul>\n<li>version control for Git, Subversion, Mercurial, Perforce, CVS, TFS supported<\/li>\n<li>tools and code assistance features for work with database and SQL in your projects<\/li>\n<li>analyze schema with UML diagrams<\/li>\n<li>track any changes made to your source files, protecting you from any accidental losses or modifications<\/li>\n<li>helps developers to understand and change their code by providing editable UML class diagrams for PHP code<\/li>\n<li>plugin repository contains 250+ IDE plugins of all kinds<\/li>\n<li>Vagrant is a handy tool, allowing you to share a development virtual machine, is natively integrated<\/li>\n<li>REST Client is integrated in the IDE<\/li>\n<li>SSH Console let you connect to any remote machine and perform various actions via SSH<\/li>\n<li>Google App Engine applications for PHP development along with ability to delegate routine deployment tasks to the IDE<\/li>\n<li>Composer (dependency manager for PHP) is supported<\/li>\n<li>pre-configured command completion for various external command-line tools, including Composer, Symfony console, Zend Framework 2 tool (ZFTool), Zend Framework 1 tool, Drush for Drupal, Tools based on Symfony console (Laravel, Doctrine)<\/li>\n<li>ability to use a remote interpreter instead of a local one with PHP based application on real server or a virtualized one created with Vagrant<\/li>\n<li>completes and checks standard tags, properties, target names, path attribute values in build files, via Phing<\/li>\n<li>same integrated development environment on Windows, Mac OS X and Linux with your single key<\/li>\n<li>Docker plugin allows user to add Docker support to existing projects, view logs, manage Docker containers<\/li>\n<li>if ToDo list is in an issue\/bug tracking system, you can configure PhpStorm to work with the issues without switching from the IDE<\/li>\n<\/ul>\n<\/ol>\n<p> &#8230; and more features can be read about from the <a target=_blank title='PHPStorm landing page' href='https:\/\/www.jetbrains.com\/phpstorm\/'>PHPStorm<\/a> website, by JetBrains.  The information above comes from the website.<\/p>\n<p>With today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/PHPStorm\/\" title='click picture'>slideshow<\/a>, we take up our introductory look at PHPStorm after the install (onto a MacBook Pro laptop using a local Apache MAMP web server) and download, opening some existant PHP code, as a PHPStorm project, which we then Run (or Execute).<\/p>\n<p>We hope this is food for thought for you, in months not starting with M (because we want to remind you to <a target=_blank title='?' href='http:\/\/www.enotes.com\/shakespeare-quotes\/beware-ides-march'>&#8220;beware the ides of March&#8221;<\/a> &#8230; boom, boom), using the great PHP language in a more integrated and dynamic environment, to hand coded, text edited PHP.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18791' onclick='var dv=document.getElementById(\"d18791\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/php\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18791' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18916' onclick='var dv=document.getElementById(\"d18916\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/debug\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18916' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Though with a large variety of scenarios with code, you can debug a piece of code from the command line &#8230; and don&#8217;t get me wrong because sometimes the command line will be the only way &#8230; the experience of &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpstorm-and-xdebug-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[85,305,306,307,576,585,652,723,725,744,932,1755,1255,1754,1377,1419,1762],"class_list":["post-18916","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-apache","tag-debug","tag-debugger","tag-debugging","tag-html","tag-ide","tag-javascript","tag-mac","tag-mac-os-x","tag-mamp","tag-php","tag-phpstorm","tag-text-editor","tag-vagrant","tag-virtual-machine","tag-webserver","tag-xdebug"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18916"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=18916"}],"version-history":[{"count":6,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18916\/revisions"}],"predecessor-version":[{"id":18946,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18916\/revisions\/18946"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=18916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=18916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=18916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}