<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tugboat</title>
    <description>The latest articles on DEV Community by Tugboat (@tugboat).</description>
    <link>https://dev.to/tugboat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F3257%2F4bd628c1-dfc8-462b-90d4-6ada0941c459.jpeg</url>
      <title>DEV Community: Tugboat</title>
      <link>https://dev.to/tugboat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tugboat"/>
    <language>en</language>
    <item>
      <title>Xdebug 3 is here: Massive performance increase, simpler config, and PHP 8 support</title>
      <dc:creator>James Sansbury</dc:creator>
      <pubDate>Wed, 25 Nov 2020 16:43:24 +0000</pubDate>
      <link>https://dev.to/tugboat/xdebug-3-is-here-massive-performance-increase-simpler-config-and-php-8-support-a4p</link>
      <guid>https://dev.to/tugboat/xdebug-3-is-here-massive-performance-increase-simpler-config-and-php-8-support-a4p</guid>
      <description>&lt;p&gt;If you're using Xdebug for PHP debugging, there's a new version that just released today: Xdebug 3. Check out the &lt;a href="https://xdebug.org/announcements/2020-11-25" rel="noopener noreferrer"&gt;announcement&lt;/a&gt;! Promising massive performance boosts, a simpler configuration paradigm, and support for the upcoming (tomorrow!) PHP 8.0 release.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1331621484607967232-603" src="https://platform.twitter.com/embed/Tweet.html?id=1331621484607967232"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1331621484607967232-603');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1331621484607967232&amp;amp;theme=dark"
  }



 &lt;/p&gt;
&lt;h2&gt;
  
  
  Upgrading
&lt;/h2&gt;

&lt;p&gt;To read about how to upgrade from Xdebug 2 to Xdebug 3, &lt;a href="https://xdebug.org/docs/upgrade_guide" rel="noopener noreferrer"&gt;read the upgrade guide&lt;/a&gt;. Some highlights below:&lt;/p&gt;
&lt;h2&gt;
  
  
  Performance
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://php.watch/articles/xdebug2-vs-3-benchmark?r" rel="noopener noreferrer"&gt;benchmarks of Xdebug 3&lt;/a&gt; have shown that Xdebug 3 is &lt;strong&gt;34% faster&lt;/strong&gt; for step debugging, and &lt;strong&gt;25% faster&lt;/strong&gt; when in &lt;code&gt;develop&lt;/code&gt; mode. In addition, if you have the Xdebug extension installed, but aren't actively using it (features are disabled), Xdebug 3 is over &lt;strong&gt;99% faster&lt;/strong&gt; than Xdebug 2.&lt;/p&gt;
&lt;h1&gt;
  
  
  Configuration highlights
&lt;/h1&gt;

&lt;p&gt;One of the big shifts with Xdebug 3 is the introduction of the &lt;code&gt;xdebug.mode&lt;/code&gt; ini setting. If you've ever struggled getting just the correct incantation or flavor of Xdebug ini settings to get debugging working, feast your eyes on this thing of beauty:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xdebug.mode=debug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No more deciphering if you need &lt;code&gt;remote_enable&lt;/code&gt; on, &lt;code&gt;profiler_enable&lt;/code&gt; on, or trying to remember what exactly &lt;code&gt;remote_autostart&lt;/code&gt; does. &lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple Xdebug modes
&lt;/h2&gt;

&lt;p&gt;You can combine Xdebug modes together with a comma. These other modes for &lt;code&gt;xdebug.mode&lt;/code&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;off&lt;/code&gt; Everything is—ahem—off. This means you can have the extension installed but disabled, and a negligible performance hit. ✨ I'm guessing you can't really combine this with the other modes? 🤷‍♂️&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;develop&lt;/code&gt; Turns on &lt;a href="https://xdebug.org/docs/develop" rel="noopener noreferrer"&gt;development aids&lt;/a&gt;. If you like stack traces or if &lt;code&gt;var_dump()&lt;/code&gt; is your friend, you'll want this setting.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;coverage&lt;/code&gt; If you're running code coverage reports with PHPUnit, turn this on.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;debug&lt;/code&gt; Enables step debugging. 😋&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gcstats&lt;/code&gt; Collect statistics about PHP's garbage collection mechanism. 🗑&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;profile&lt;/code&gt; Use this to analyze performance with tools like KCacheGrind. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trace&lt;/code&gt; Enables the Function Trace feature, which allows you record every function call, including arguments, variable assignment, and return value that is made during a request to a file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time will tell, but I'm guessing &lt;code&gt;xdebug.mode&lt;/code&gt; on most of my projects will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xdebug.mode=develop,debug,coverage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Starting a step debug session
&lt;/h2&gt;

&lt;p&gt;Remember the &lt;code&gt;XDEBUG_CONFIG="idekey=wtf"&lt;/code&gt; days? No longer. Now it's simplified to an &lt;code&gt;XDEBUG_SESSION&lt;/code&gt; environment variable to turn on step debugging. Set this environment variable to the key you'd like for that step debug session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;XDEBUG_SESSION=wtf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step debugging? Port 9003
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F91gka35xg2xwi74z2gjt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F91gka35xg2xwi74z2gjt.gif" alt="Caution" width="480" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Heads up:&lt;/strong&gt; the default step debugging port has changed from port 9000 to port 9003. &lt;/p&gt;

&lt;h1&gt;
  
  
  Win, win, win: performance, simpler config, PHP 8 support
&lt;/h1&gt;

&lt;p&gt;What's not to love about this release? I'm excited to be able to have the extension installed and available without a huge performance hit. I'm looking forward to simpler configuration. And tomorrow, PHP 8.0 will land, which is the first release to have &lt;a href="https://dev.to/tugboatqa/php-8-0-is-almost-here-how-to-turn-on-jit-compiling-1l6l"&gt;JIT compiling&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>news</category>
      <category>php</category>
      <category>webdev</category>
      <category>laravel</category>
    </item>
    <item>
      <title>PHP 8.0 is here! How to turn on JIT compiling</title>
      <dc:creator>James Sansbury</dc:creator>
      <pubDate>Mon, 23 Nov 2020 20:30:25 +0000</pubDate>
      <link>https://dev.to/tugboat/php-8-0-is-almost-here-how-to-turn-on-jit-compiling-1l6l</link>
      <guid>https://dev.to/tugboat/php-8-0-is-almost-here-how-to-turn-on-jit-compiling-1l6l</guid>
      <description>&lt;p&gt;As of &lt;a href="https://wiki.php.net/todo/php80" rel="noopener noreferrer"&gt;Nov 26, 2020&lt;/a&gt; PHP 8.0 will be “generally available.” (I learned today that that’s what the GA means on that page.)&lt;/p&gt;

&lt;p&gt;Folks have been benchmarking and found that an upgrade to PHP 8.0 will likely mean a performance boost for your website. Faster loading pages is important both for SEO purposes, and of course for the actual users of your sites. &lt;/p&gt;

&lt;p&gt;PHP 8.0 now ships with a JIT compiler that can increase that performance boost even further. JIT stands for “Just in time,” and means that PHP can compile its code directly into machine code (code that the CPU understands) without needing the help of an interpretation layer. For CPU-intensive tasks, having a JIT compiler in PHP boasts &lt;em&gt;significant&lt;/em&gt; performance gains.&lt;/p&gt;

&lt;p&gt;PHP developers everywhere are missing out on this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://xkcd.com/303/" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjbrwv9is0lo4a9cmmw6.png" alt="Compiling comic from XKCD: https://xkcd.com/303/" width="413" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re interested in learning more about the new stuff in PHP 8.0, here’s a few articles to check out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://torquemag.io/2020/11/php-8/" rel="noopener noreferrer"&gt;https://torquemag.io/2020/11/php-8/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stitcher.io/blog/php-jit" rel="noopener noreferrer"&gt;https://stitcher.io/blog/php-jit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thephp.website/en/issue/php-8-jit/" rel="noopener noreferrer"&gt;https://thephp.website/en/issue/php-8-jit/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🔦 How to turn on JIT compiling
&lt;/h2&gt;

&lt;p&gt;If you’ve been using PHP 7.x, you’re probably familiar with the OPcache extension. (And if you’re not, go make sure it’s turned on now. It’s a huge performance boost.)&lt;/p&gt;

&lt;p&gt;For PHP 8.0, the JIT compiling is enabled via this same OPcache extension. So step one in getting JIT compiling turned on for your project is making sure the OPcache extension is installed and enabled.&lt;/p&gt;

&lt;p&gt;The process for &lt;a href="https://www.php.net/manual/en/opcache.installation.php" rel="noopener noreferrer"&gt;installing the OPcache extension&lt;/a&gt; will depend a lot on the platform you’re running PHP on. Check the docs for your flavor of Linux. If you’re using the &lt;a href="https://hub.docker.com/_/php" rel="noopener noreferrer"&gt;official PHP Docker images&lt;/a&gt;, installing it is pretty easy:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker-php-ext-install opcache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To check if you’ve got it installed, you can run &lt;code&gt;php -i&lt;/code&gt; on the command-line to print out &lt;a href="https://www.php.net/manual/en/function.phpinfo.php" rel="noopener noreferrer"&gt;&lt;code&gt;phpinfo()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php -i | grep 'opcache\.enable '
opcache.enable =&amp;gt; On =&amp;gt; On
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  🖊️ Tweak the Opcache settings to enable JIT compiling
&lt;/h2&gt;

&lt;p&gt;Now that you have the Opcache extension installed, that doesn’t mean JIT is turned on. We’ve got to override a few default ini settings to actually enable JIT compiling. To do this, you can see if you can find the existing opcache.ini file. Here’s how I usually do that (again, with &lt;code&gt;phpinfo()&lt;/code&gt;).&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -i | grep opcache\.ini
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;As you can see, this is a Docker image I’m using, so any changes I make here are liable to get wiped out, but I’m okay with that for now. I’m just tinkering at this point. I’m going to edit that file and add the following settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Turn on the OPcache for command-line PHP, like drush or 
# wp-cli, etc.
opcache.enable_cli=1

# The amount of shared memory to reserve for compiled JIT
# code. A zero value disables the JIT.
opcache.jit_buffer_size=50M

# JIT control options. Either accepts a string or a 4 digit 
# int for advanced controls. See 
# https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit
opcache.jit=tracing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: if you wanted a more permanent solution for Docker, create your own ini file that gets copied or mounted into the &lt;code&gt;$PHP_INI_DIR/conf.d/&lt;/code&gt; directory in your container.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For more details on these settings, check out the &lt;a href="https://www.php.net/manual/en/opcache.configuration.php" rel="noopener noreferrer"&gt;OPcache Runtime Configuration&lt;/a&gt; or the &lt;a href="https://wiki.php.net/rfc/jit" rel="noopener noreferrer"&gt;PHP RFC: JIT&lt;/a&gt;. You read that right: three three-letter acronyms. 🤦‍♂️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flko6ayorpqx457slbg41.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flko6ayorpqx457slbg41.gif" alt="OMGWTFBBQ" width="458" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can double check that your settings worked by using &lt;code&gt;php -i&lt;/code&gt; again:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ php -i | grep -E '^opcache\.(enable_cli|jit|jit_buffer_size) '
opcache.enable_cli =&amp;gt; On =&amp;gt; On
opcache.jit =&amp;gt; tracing =&amp;gt; tracing
opcache.jit_buffer_size =&amp;gt; 50M =&amp;gt; 50M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That’s it! You’re now taking advantage of JIT compiling in PHP 8.0. (And if you’re using the Apache PHP module, don’t forget to &lt;code&gt;apache2ctl graceful&lt;/code&gt;). Go forth and test. 🧪&lt;/p&gt;

</description>
      <category>php</category>
      <category>performance</category>
      <category>webdev</category>
      <category>laravel</category>
    </item>
  </channel>
</rss>
