<?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: James Sansbury</title>
    <description>The latest articles on DEV Community by James Sansbury (@q0rban).</description>
    <link>https://dev.to/q0rban</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%2Fuser%2Fprofile_image%2F501141%2Fcee98424-f132-4cd0-903f-972b34a97fef.png</url>
      <title>DEV Community: James Sansbury</title>
      <link>https://dev.to/q0rban</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/q0rban"/>
    <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>What the dill with pecl: Is pear still around for PHP 8?</title>
      <dc:creator>James Sansbury</dc:creator>
      <pubDate>Tue, 24 Nov 2020 14:57:26 +0000</pubDate>
      <link>https://dev.to/q0rban/what-the-dill-with-pecl-is-pear-still-around-for-php-8-154j</link>
      <guid>https://dev.to/q0rban/what-the-dill-with-pecl-is-pear-still-around-for-php-8-154j</guid>
      <description>&lt;p&gt;It's a bit confusing determining whether pear/pecl are still around in PHP 8.0. There's been talk of removing it entirely from PHP for years (just do some searching and you'll see the various RFCs).&lt;/p&gt;

&lt;p&gt;There’s a lot of confusing stuff out there. The official PHP Docker images currently do not have it installed for their 8.0-RC images, &lt;a href="https://github.com/docker-library/php/blob/3dc9a6988d478fae0f0b8b871d10e611b50e3d0c/7.4/buster/apache/Dockerfile#L225-L227"&gt;citing that pear has been removed in PHP 8.0&lt;/a&gt;. However PHP's documentation on &lt;a href="https://www.php.net/manual/en/migration80.php"&gt;Migrating from PHP 7.4.x to PHP 8.0.x&lt;/a&gt; doesn’t mention removal of it. In fact, it even &lt;a href="https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.xmlrpc"&gt;mentions&lt;/a&gt; that the XML-RPC extension "has been moved to PECL." &lt;/p&gt;

&lt;p&gt;So what gives?&lt;/p&gt;

&lt;p&gt;It appears that the &lt;code&gt;--with-pear&lt;/code&gt; option is still around for configuring PHP builds from source. When you use it, the build states:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configure: WARNING: The --with-pear option is deprecated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the same warning you'll see if you build PHP 7.4.&lt;/p&gt;

&lt;p&gt;As far as I can tell, Pear and Pecl are here to stay in PHP 8.0. As such, I created &lt;a href="https://github.com/docker-library/php/pull/1088"&gt;a Pull Request on the official PHP Docker images&lt;/a&gt; to add the &lt;code&gt;--with-pear&lt;/code&gt; option to the 8.0-RC builds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⁉️ Those in the know: can you weigh in on this? Are pear and pecl still going to be the official way to install Pecl extensions in PHP 8.0.x?&lt;/strong&gt; Or should we start transitioning to &lt;a href="https://github.com/FriendsOfPHP/pickle"&gt;pickle&lt;/a&gt;?&lt;/p&gt;

</description>
      <category>php</category>
      <category>docker</category>
      <category>help</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>
    <item>
      <title>"It worked on my local!" 😭</title>
      <dc:creator>James Sansbury</dc:creator>
      <pubDate>Wed, 04 Nov 2020 22:12:40 +0000</pubDate>
      <link>https://dev.to/q0rban/it-worked-on-my-local-4bbh</link>
      <guid>https://dev.to/q0rban/it-worked-on-my-local-4bbh</guid>
      <description>&lt;p&gt;If you’re in webdev and stuck with a single staging or testing server, my heart goes out to you. That probably means you and your team work real hard on designing and developing amazing things, and then at the end of the sprint when it’s all supposed to come together in a glorious, jaw-dropping demo, something goes 💥.&lt;/p&gt;

&lt;p&gt;😭&lt;/p&gt;

&lt;p&gt;Developers are confused, Project Managers are embarrassed, and Stakeholders are frustrated. Morale tanks like a swiss cheese submarine 🧀. The team is stuck with a few bad options: ship the broken thing and hope to have time to fix it later, scrub the launch and do it right, or pull an all-nighter to hotfix the release. &lt;/p&gt;

&lt;p&gt;I don’t know about you, but I don’t like any of those options.&lt;/p&gt;

&lt;p&gt;What caused the “boom”? Often the team will find it was something small, like a missing semicolon, or maybe as embarrassing as [cough, cough] &lt;em&gt;misunderstanding entirely how a new feature was supposed to work&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But those things are actually symptoms of a deeper issue. Underneath the huge gaping crater of that failed demo is a pernicious anti-pattern in the entire agile webdev process: a single staging / testing server. &lt;/p&gt;

&lt;h1&gt;
  
  
  The bottleneck of a single staging server
&lt;/h1&gt;

&lt;p&gt;Given the rise of tools like Docker and Kubernetes, the amount of time, money, and hair lost to the bottleneck of limited staging servers is truly a tragedy. Friends, how are we still in this place?! We don’t need to be stuck with just one or two servers to test on. &lt;/p&gt;

&lt;p&gt;We talk all day about “Agile”, “Scrum”, or “Kanban”, but our process doesn’t actually &lt;em&gt;work&lt;/em&gt; that way. We can’t see what is being worked on in an “agile” manner, and then guess what happens: 💩 meet fan.&lt;/p&gt;

&lt;p&gt;To me, this bottleneck is &lt;strong&gt;the most frustrating anti-pattern&lt;/strong&gt; of our day. The technology is there. And, there are tools that make use of it. (If you’re in the market, &lt;a href="https://www.tugboat.qa"&gt;Tugboat&lt;/a&gt; is &lt;em&gt;obviously&lt;/em&gt; the best option. 💅 )&lt;/p&gt;

&lt;h1&gt;
  
  
  Remove the bottleneck: ship every commit.
&lt;/h1&gt;

&lt;p&gt;No matter where you host or what your budget is, there’s a solution to this problem. Stop being reactive and start being proactive with your QA and demos. Get some tooling in place to give you automated, fully working website previews for every pull request. &lt;/p&gt;

&lt;p&gt;Test everything all the time, and demo anything any time. And if you're not sure how, reach out, I'm glad to help.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>webdev</category>
      <category>agile</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
