<?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: Ben Ramsey</title>
    <description>The latest articles on DEV Community by Ben Ramsey (@ramsey).</description>
    <link>https://dev.to/ramsey</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%2F152140%2F927fa0bd-4992-4c2c-b560-eba7158ac365.jpg</url>
      <title>DEV Community: Ben Ramsey</title>
      <link>https://dev.to/ramsey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramsey"/>
    <language>en</language>
    <item>
      <title>Testing the PDO_ODBC driver on macOS</title>
      <dc:creator>Ben Ramsey</dc:creator>
      <pubDate>Wed, 12 May 2021 23:27:23 +0000</pubDate>
      <link>https://dev.to/ramsey/testing-the-pdoodbc-driver-on-macos-55n1</link>
      <guid>https://dev.to/ramsey/testing-the-pdoodbc-driver-on-macos-55n1</guid>
      <description>&lt;p&gt;I response to &lt;a href="https://github.com/cmb69" rel="noopener noreferrer"&gt;Christoph’s&lt;/a&gt; &lt;a href="https://github.com/php/php-src/pull/6935#issuecomment-834270441" rel="noopener noreferrer"&gt;comment on PR #6935&lt;/a&gt;, I wanted to check to see exactly what PHP returns when calling &lt;code&gt;PDO::getAttribute()&lt;/code&gt; on &lt;code&gt;PDO_ODBC&lt;/code&gt; with &lt;code&gt;PDO::ATTR_SERVER_INFO&lt;/code&gt; and &lt;code&gt;PDO::ATTR_SERVER_VERSION&lt;/code&gt;.  &lt;a href="https://github.com/php/php-src/blob/01b3fc03c30c6cb85038250bb5640be3a09c6a32/ext/pdo_odbc/odbc_driver.c#L356-L372" rel="noopener noreferrer"&gt;Looking at the code&lt;/a&gt;, I could tell that it breaks and returns a &lt;code&gt;0&lt;/code&gt;.  I wasn’t sure how it reacted beyond that, and I wanted to test it in PHP to see what would happen.&lt;/p&gt;

&lt;p&gt;To do this, I needed to be able to connect to a database using ODBC on macOS. Since I primarily use MySQL or PostgreSQL, I haven’t used ODBC to connect to a database in almost 20 years.&lt;/p&gt;

&lt;p&gt;My PHP build already had &lt;code&gt;PDO_ODBC&lt;/code&gt; installed, so I didn’t need to rebuild it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;php &lt;span class="nt"&gt;-m&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; odbc
&lt;span class="go"&gt;odbc
PDO_ODBC
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, I checked to see whether &lt;a href="http://www.unixodbc.org" rel="noopener noreferrer"&gt;unixODBC&lt;/a&gt; was installed, and I wanted to connect to a &lt;a href="https://mariadb.com" rel="noopener noreferrer"&gt;MariaDB&lt;/a&gt; server, so I installed the &lt;code&gt;unixodbc&lt;/code&gt; and &lt;code&gt;mariadb-connector-odbc&lt;/code&gt; packages with &lt;a href="https://brew.sh" rel="noopener noreferrer"&gt;Homebrew&lt;/a&gt;. (It turned out that &lt;code&gt;unixodbc&lt;/code&gt; was already installed on my system through Homebrew.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;unixodbc mariadb-connector-odbc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From here, I created a temporary file with the following contents (I named it &lt;code&gt;mariadb-odbc.ini&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[MariaDB ODBC 3.1 Driver]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;MariaDB Connector/ODBC v.3.1&lt;/span&gt;
&lt;span class="py"&gt;Driver&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/usr/local/lib/mariadb/libmaodbc.dylib&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;libmaodbc&lt;/code&gt; driver is provided by &lt;code&gt;mariadb-connector-odbc&lt;/code&gt;, and the path to the &lt;code&gt;Driver&lt;/code&gt; is based on where Homebrew put it, so if you’re following along and attempting to do the same, double-check the location on your system. &lt;/p&gt;

&lt;p&gt;Then, I imported the driver configuration using &lt;code&gt;odbcinst&lt;/code&gt;, which comes with unixODBC. &lt;a href="http://www.unixodbc.org/odbcinst.html" rel="noopener noreferrer"&gt;Check the &lt;code&gt;odbcinst&lt;/code&gt; documentation&lt;/a&gt; for more information about the above INI file format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;odbcinst &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; mariadb-odbc.ini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds the configuration to &lt;code&gt;/usr/local/etc/odbcinst.ini&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I then used Docker to create a MariaDB container that I could connect to using the ODBC driver.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 3306:3306 &lt;span class="nt"&gt;--name&lt;/span&gt; mariadb &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;password &lt;span class="nt"&gt;-d&lt;/span&gt; mariadb:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the container up and running, I launched &lt;a href="https://psysh.org" rel="noopener noreferrer"&gt;PsySH&lt;/a&gt; and started entering expressions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=&amp;gt; $dsn = "odbc:Driver={MariaDB ODBC 3.1 Driver};Server=127.0.0.1;Database=mysql;User=root;Password=password;Option=3;"

&amp;gt;&amp;gt;&amp;gt; $pdo = new PDO($dsn)
=&amp;gt; PDO {#3907
     inTransaction: false,
     attributes: {
       CASE: NATURAL,
       ERRMODE: EXCEPTION,
       PERSISTENT: false,
       DRIVER_NAME: "odbc",
       ORACLE_NULLS: NATURAL,
       CLIENT_VERSION: "ODBC-unixODBC",
       STATEMENT_CLASS: [
         "PDOStatement",
       ],
       DEFAULT_FETCH_MODE: BOTH,
     },
   }

&amp;gt;&amp;gt;&amp;gt; $pdo-&amp;gt;getAttribute(PDO::ATTR_SERVER_INFO)
PDOException with message 'SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute'

&amp;gt;&amp;gt;&amp;gt; $pdo-&amp;gt;getAttribute(PDO::ATTR_SERVER_VERSION)
PDOException with message 'SQLSTATE[IM001]: Driver does not support this function: driver does not support that attribute'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, there we go. &lt;code&gt;PDO::getAttribute()&lt;/code&gt; throws a &lt;code&gt;PDOException&lt;/code&gt; when it doesn’t support an attribute.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://github.com/NattyNarwhal" rel="noopener noreferrer"&gt;Calvin Buckley&lt;/a&gt;, these attributes will no longer throw exceptions and will instead &lt;a href="https://github.com/php/php-src/pull/6935" rel="noopener noreferrer"&gt;return actual values in PHP 8.1&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; $pdo-&amp;gt;getAttribute(PDO::ATTR_SERVER_INFO)
=&amp;gt; "MariaDB"

&amp;gt;&amp;gt;&amp;gt; $pdo-&amp;gt;getAttribute(PDO::ATTR_SERVER_VERSION)
=&amp;gt; "10.05.000009"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>odbc</category>
      <category>mariadb</category>
    </item>
    <item>
      <title>Using CLion with php-src</title>
      <dc:creator>Ben Ramsey</dc:creator>
      <pubDate>Mon, 10 May 2021 17:08:02 +0000</pubDate>
      <link>https://dev.to/ramsey/using-clion-with-php-src-4me0</link>
      <guid>https://dev.to/ramsey/using-clion-with-php-src-4me0</guid>
      <description>&lt;p&gt;I’ve cloned and built &lt;a href="https://github.com/php/php-src" rel="noopener noreferrer"&gt;php-src&lt;/a&gt; numerous times over the years, on a variety of platforms, but I’ve never worked with it in an IDE. A long-time &lt;a href="https://www.vim.org" rel="noopener noreferrer"&gt;Vim&lt;/a&gt; user, I’ve only begun using &lt;a href="https://www.jetbrains.com/phpstorm/" rel="noopener noreferrer"&gt;PhpStorm&lt;/a&gt; over the last year and a half, after seeing how &lt;a href="https://www.jetbrains.com/idea/" rel="noopener noreferrer"&gt;IntelliJ&lt;/a&gt; helped me easily navigate an open source Java project. So, in setting up php-src for &lt;a href="https://dev.to/ramsey/i-m-a-release-manager-for-php-8-1-24i2"&gt;release management&lt;/a&gt; tasks, I wanted to give &lt;a href="https://www.jetbrains.com/clion/" rel="noopener noreferrer"&gt;CLion&lt;/a&gt; a try.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting php-src ready for CLion
&lt;/h2&gt;

&lt;p&gt;When opening existing source code or cloning a repo with CLion, it assumes the project already supports &lt;a href="https://cmake.org" rel="noopener noreferrer"&gt;CMake&lt;/a&gt; tooling for builds. For someone new to C and using a project that doesn’t use CMake, this can be confusing and frustrating. Since php-src isn’t a CMake project, CLion will display warnings at the top of every open file, saying that a “CMake project is not loaded,” giving you the option to select or generate a &lt;code&gt;CMakeLists.txt&lt;/code&gt; file. You can try to do this for php-src, but there’s a better way.&lt;/p&gt;

&lt;p&gt;CLion also supports &lt;a href="https://www.jetbrains.com/help/clion/compilation-database.html" rel="noopener noreferrer"&gt;JSON compilation databases&lt;/a&gt;. To generate one and have CLion recognize php-src as a &lt;a href="https://www.jetbrains.com/help/clion/compilation-database.html" rel="noopener noreferrer"&gt;compilation database project&lt;/a&gt;, you’ll need to do the following &lt;em&gt;before&lt;/em&gt; opening php-src in CLion. If you’ve already opened it in CLion, that’s okay. Delete the &lt;code&gt;.idea/&lt;/code&gt; folder that CLion creates, and then do the following. (I could not figure out a way to make CLion recognize the compilation database if I had already opened the project in CLion. It seems the compilation database must exist the first time you open the project in order for CLion to recognize it.)&lt;/p&gt;

&lt;p&gt;You’ll need the &lt;code&gt;compiledb&lt;/code&gt; Python tool to generate the compilation database. It wraps the &lt;code&gt;make&lt;/code&gt; command, so when you run it with &lt;code&gt;make&lt;/code&gt;, it captures all the sources and creates a &lt;code&gt;compile_commands.json&lt;/code&gt; file. Then, when you open the project in CLion for the first time, it will recognize your project as a compilation database project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;compiledb

git clone https://github.com/php/php-src.git ~/repos/php/php-src
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/repos/php/php-src
./buildconf
./configure &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/builds/php/8.1.0-dev &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--disable-all&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--disable-cgi&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--enable-debug&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--enable-zts&lt;/span&gt;

compiledb make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see here, I use &lt;code&gt;compiledb&lt;/code&gt; to call &lt;code&gt;make&lt;/code&gt;. In this way, &lt;code&gt;compiledb&lt;/code&gt; can learn about all the sources for your build.&lt;/p&gt;

&lt;p&gt;You may also pass &lt;code&gt;-jN&lt;/code&gt; to &lt;code&gt;make&lt;/code&gt;, where &lt;code&gt;N&lt;/code&gt; is the number of CPU cores your system has available. This will greatly speed up compilation.&lt;/p&gt;

&lt;p&gt;You can run &lt;code&gt;nproc&lt;/code&gt; to find out how many cores you have.  On my system, I have 12 cores, so I run the command like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;compiledb make &lt;span class="nt"&gt;-j12&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my example, I pass &lt;code&gt;--prefix&lt;/code&gt; to &lt;code&gt;configure&lt;/code&gt;, but this isn’t necessary since I’m not going to run &lt;code&gt;make install&lt;/code&gt;. Once &lt;code&gt;make&lt;/code&gt; has finished building PHP, you can find the newly-built PHP CLI at &lt;code&gt;sapi/cli/php&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;./sapi/cli/php &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;span class="go"&gt;PHP 8.1.0-dev (cli) (built: May  6 2021 18:27:37) (ZTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies

&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;./sapi/cli/php &lt;span class="nt"&gt;-m&lt;/span&gt;
&lt;span class="go"&gt;[PHP Modules]
Core
date
hash
json
pcre
Reflection
SPL
standard

[Zend Modules]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up CLion to build and run PHP
&lt;/h2&gt;

&lt;p&gt;Now that php-src has a compilation database (which needs to be updated each time you change your build with &lt;code&gt;configure&lt;/code&gt; or if you add new sources that get included in &lt;code&gt;make&lt;/code&gt;), you can open it in CLion.&lt;/p&gt;

&lt;p&gt;Launch CLion to get to the welcome screen and choose to open a project from existing sources.&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%2Fuploads%2Farticles%2F453rmnfowe292buy9ys4.png" 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%2Fuploads%2Farticles%2F453rmnfowe292buy9ys4.png" alt="CLion welcome screen" width="800" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse to your php-src folder and, rather than selecting the folder to open, select the &lt;code&gt;compile_commands.json&lt;/code&gt; file that  &lt;code&gt;compiledb&lt;/code&gt; generated.&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%2Fuploads%2Farticles%2Fpc3pflycdgmxdllyhryp.png" 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%2Fuploads%2Farticles%2Fpc3pflycdgmxdllyhryp.png" alt="File selection dialog highlighting compile_commands.json" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When CLion prompts you, choose to open it as a project.&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%2Fuploads%2Farticles%2F1qt7hutpz8ncm1ihc1ou.png" 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%2Fuploads%2Farticles%2F1qt7hutpz8ncm1ihc1ou.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CLion will now open the project and inform you that it successfully imported the compilation database project.&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%2Fuploads%2Farticles%2Ffmbg70s83uq8weqcemv5.png" 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%2Fuploads%2Farticles%2Ffmbg70s83uq8weqcemv5.png" alt="Compilation database project successfully imported" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With CLion open, you’ll now &lt;a href="https://www.jetbrains.com/help/clion/custom-build-targets.html" rel="noopener noreferrer"&gt;create custom build targets&lt;/a&gt; for &lt;code&gt;make&lt;/code&gt; and &lt;code&gt;make clean&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Open CLion Preferences and go to &lt;em&gt;Build, Execution, Deployment&lt;/em&gt; -&amp;gt; &lt;em&gt;Custom Build Targets&lt;/em&gt;. Create a new build target, named something like “Build PHP.” Then, next to the empty Build and Clean fields, click the &lt;em&gt;more&lt;/em&gt; button (with three dots). This will open an External Tools window. Use the +-button here to create two external tools.&lt;/p&gt;

&lt;p&gt;I named the first one “Build with Make.” The program is &lt;code&gt;make&lt;/code&gt; and I added &lt;code&gt;-j12&lt;/code&gt; to the arguments for a faster build (see earlier). You might also consider using &lt;code&gt;compiledb&lt;/code&gt; as the program, with &lt;code&gt;make -j12&lt;/code&gt; as the arguments.&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%2Fuploads%2Farticles%2Fdl485qaqihjzbm256urx.png" 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%2Fuploads%2Farticles%2Fdl485qaqihjzbm256urx.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I named the second tool “Clean with Make” and used &lt;code&gt;make&lt;/code&gt; as the program and &lt;code&gt;clean&lt;/code&gt; as the argument.&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%2Fuploads%2Farticles%2Fniwv1ckzq8kd24zg5f1f.png" 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%2Fuploads%2Farticles%2Fniwv1ckzq8kd24zg5f1f.png" alt="" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, you can click OK to close these windows and the External Tools window, and select the proper tools to use with your Build PHP target.&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%2Fuploads%2Farticles%2Fr1pyy581zuvguvw82jik.png" 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%2Fuploads%2Farticles%2Fr1pyy581zuvguvw82jik.png" alt="" width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you’ll want to &lt;a href="https://www.jetbrains.com/help/clion/custom-build-targets.html#custom-rundebug" rel="noopener noreferrer"&gt;create a custom run/debug configuration&lt;/a&gt;.  To do this, go to &lt;em&gt;Run&lt;/em&gt; -&amp;gt; &lt;em&gt;Edit Configurations…&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Use the +-button to create a new configuration and choose &lt;strong&gt;Custom Build Application&lt;/strong&gt; from the menu that appears. I named my configuration “Build PHP” and I chose my “Build PHP” target (created earlier) from the Target dropdown list. For the executable, I entered the path to the PHP CLI built by this project (remember, it’s at &lt;code&gt;sapi/cli/php&lt;/code&gt;). Last, I checked “Redirect input from” and entered the JetBrains variable &lt;code&gt;$FilePrompt$&lt;/code&gt;. In this way, whenever you chose to run PHP from within CLion, it will prompt you with a file dialog to execute through the PHP interpreter. This lets you select a PHP script to run and test/debug whatever feature you’re working on.&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%2Fuploads%2Farticles%2Fxii747wxpxgsznbkebtx.png" 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%2Fuploads%2Farticles%2Fxii747wxpxgsznbkebtx.png" alt="" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, click the hammer icon (🔨) or select &lt;em&gt;Build&lt;/em&gt; -&amp;gt; &lt;em&gt;Build Project&lt;/em&gt; to build PHP, or select &lt;em&gt;Build&lt;/em&gt; -&amp;gt; &lt;em&gt;Clean&lt;/em&gt; to run the &lt;code&gt;make clean&lt;/code&gt; command. &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%2Fuploads%2Farticles%2Fjb32s6ksfbrpxyg9p58q.png" 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%2Fuploads%2Farticles%2Fjb32s6ksfbrpxyg9p58q.png" alt="Output after running " width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you click the play icon (▶️) or choose &lt;em&gt;Run&lt;/em&gt; -&amp;gt; &lt;em&gt;Run ‘Build PHP’&lt;/em&gt;, it will prompt you to select a file and run that file as a PHP script. In the following, I’ve selected one of the &lt;code&gt;.phpt&lt;/code&gt; tests to execute this way.&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%2Fuploads%2Farticles%2Fweji3r4ftbmemrse4x56.png" 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%2Fuploads%2Farticles%2Fweji3r4ftbmemrse4x56.png" alt="Using the file selection dialog to select a PHPT file to run" width="800" height="506"&gt;&lt;/a&gt;&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%2Fuploads%2Farticles%2Fgq5shyb2g9tyfw50mik5.png" 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%2Fuploads%2Farticles%2Fgq5shyb2g9tyfw50mik5.png" alt="Output after running the PHPT file" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step debugging through php-src
&lt;/h2&gt;

&lt;p&gt;One of the primary reasons I wanted to use an IDE to work with php-src is for the debugging tools. With everything set up as described earlier, I’m able to run a PHP script and break on breakpoints in the C source code.&lt;/p&gt;

&lt;p&gt;As an example, I created a PHP script named &lt;code&gt;date-debug.php&lt;/code&gt; and added the following code to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Y-m-d H:i:s'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, I opened &lt;code&gt;ext/date/php_date.c&lt;/code&gt; and placed a breakpoint in the &lt;code&gt;php_date()&lt;/code&gt; function. You can see the breakpoint in the following screenshot. I placed it right after the &lt;code&gt;ZEND_PARSE_PARAMETERS&lt;/code&gt; block.&lt;/p&gt;

&lt;p&gt;When you click the debug icon (🪲) or choose &lt;em&gt;Run&lt;/em&gt; -&amp;gt; &lt;em&gt;Debug ‘Build PHP’&lt;/em&gt;, CLion will prompt you to select a file, just like it does when when you click the play icon, as described earlier. When I choose the &lt;code&gt;date-debug.php&lt;/code&gt; file, it begins executing it and then stops at the breakpoint in the C code, which happens to be the code called when using the PHP &lt;code&gt;date()&lt;/code&gt; function. As you can see, I’m now able to examine the memory and variables in this function, including the &lt;a href="https://www.phpinternalsbook.com/php7/zvals.html" rel="noopener noreferrer"&gt;zvals&lt;/a&gt;.&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%2Fuploads%2Farticles%2F97o3y6iglzvkdg3pdqwv.png" 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%2Fuploads%2Farticles%2F97o3y6iglzvkdg3pdqwv.png" alt="Inspecting variables at a breakpoint in the C source code for PHP" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>clion</category>
      <category>jetbrains</category>
    </item>
    <item>
      <title>I’m a release manager for PHP 8.1!</title>
      <dc:creator>Ben Ramsey</dc:creator>
      <pubDate>Sun, 09 May 2021 18:58:14 +0000</pubDate>
      <link>https://dev.to/ramsey/i-m-a-release-manager-for-php-8-1-24i2</link>
      <guid>https://dev.to/ramsey/i-m-a-release-manager-for-php-8-1-24i2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;My permanent blog at &lt;a href="https://benramsey.com" rel="noopener noreferrer"&gt;benramsey.com&lt;/a&gt; is in a state where I am unable to update it. It’s a long story that involves versions of Ruby gems removed from the repository, trapping me in a tangled web of &lt;a href="https://jekyllrb.com" rel="noopener noreferrer"&gt;Jekyll&lt;/a&gt; dependency hell, and I haven’t had the stomach to unravel it. In the meantime, I’ll be posting here at &lt;a href="https://dev.to/ramsey"&gt;dev.to/ramsey&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Last year, I tossed my hat in the ring to volunteer as a release manager for PHP 8.0, but I lost the vote to &lt;a href="https://github.com/carusogabriel" rel="noopener noreferrer"&gt;Gabriel Caruso&lt;/a&gt;, who has shown himself to be a very capable RM for the 8.0 series (congrats, Gabriel, and great work!). This year, when &lt;a href="https://externals.io/message/113334" rel="noopener noreferrer"&gt;Sara announced the RM selection process&lt;/a&gt; for PHP 8.1, I almost decided against volunteering, but I finally decided to go for it, and I’m glad I did.&lt;/p&gt;

&lt;p&gt;Each set of release managers is usually comprised of a veteran RM and a rookie. This year, when &lt;a href="https://twitter.com/krakjoe" rel="noopener noreferrer"&gt;Joe Watkins&lt;/a&gt; volunteered as the veteran RM, he asked to take on two rookies. As a result, &lt;a href="https://github.com/patrickallaert" rel="noopener noreferrer"&gt;Patrick Allaert&lt;/a&gt; and I were &lt;a href="https://wiki.php.net/todo/php81" rel="noopener noreferrer"&gt;both selected as rookie RMs for the 8.1 series&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;PHP release managers manage the release process, create a roadmap for the release, facilitate discussions and decisions about what goes into a release, package the releases, etc. It’s a commitment of about three-and-a-half years, as they shepherd their minor version from alpha to beta to RC to GA to active support to security support and, finally, end-of-life. The &lt;a href="https://www.php.net/supported-versions.php" rel="noopener noreferrer"&gt;supported versions&lt;/a&gt; page at php.net provides a good overview of this cycle.&lt;/p&gt;

&lt;p&gt;You can read more about the PHP release process here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wiki.php.net/rfc/releaseprocess" rel="noopener noreferrer"&gt;Request for Comments: Release Process&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/php/php-src/blob/master/docs/release-process.md" rel="noopener noreferrer"&gt;PHP release process&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, &lt;a href="https://twitter.com/shocm" rel="noopener noreferrer"&gt;Eric Van Johnson&lt;/a&gt; has published a three-part interview in &lt;em&gt;php[architect]&lt;/em&gt; magazine with PHP 8.0 release managers Sara Golemon and Gabriel Caruso. They go into a lot of the specifics.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.phparch.com/article/community-corner-php-8-release-managers-interview-with-sara-golemon-and-gabriel-caruso-part-1/" rel="noopener noreferrer"&gt;Community Corner: PHP 8 Release Managers: Interview with Sara Golemon and Gabriel Caruso, Part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.phparch.com/article/community-corner-php-8-release-managers-interview-with-sara-golemon-and-gabriel-caruso-part-two/" rel="noopener noreferrer"&gt;Part 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.phparch.com/article/community-corner-php-8-release-managers-interview-with-sara-golemon-and-gabriel-caruso-part-three/" rel="noopener noreferrer"&gt;Part 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you so much to everyone for entrusting me to serve as one of the release managers for  PHP 8.1! I look forward to working with Joe and Patrick over the next three-and-a-half years.&lt;/p&gt;

</description>
      <category>php</category>
    </item>
    <item>
      <title>Thoughts on Software Architecture</title>
      <dc:creator>Ben Ramsey</dc:creator>
      <pubDate>Thu, 18 Apr 2019 13:51:43 +0000</pubDate>
      <link>https://dev.to/ramsey/thoughts-on-software-architecture-898</link>
      <guid>https://dev.to/ramsey/thoughts-on-software-architecture-898</guid>
      <description>&lt;p&gt;&lt;em&gt;I originally posted this as &lt;a href="https://twitter.com/ramsey/status/1118331261079228417" rel="noopener noreferrer"&gt;a thread on Twitter&lt;/a&gt; in response to &lt;a href="https://twitter.com/ThePracticalDev/status/1118318764930551813" rel="noopener noreferrer"&gt;a recent #DevDiscuss topic&lt;/a&gt;. I'm reposting here to preserve these thoughts and for others to easily refer to it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Software architecture concerns itself with how the software is built, including high-level design and technical standards, as well as coding standards, tools, platforms, etc.&lt;sup&gt;&lt;a href="https://en.wikipedia.org/wiki/Software_architect" rel="noopener noreferrer"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;A software architect is a software developer who has become an expert in these things through extensive experience practicing them and learning from others.&lt;/p&gt;

&lt;p&gt;A software architect (as a role) is a leader in the organization, helping the team turn a problem domain into software. They are able to grasp the concepts of the domain and communicate how to represent them in code. Additionally, they work with the team to set standards and develop practices that will ensure the quality of the software created and the long-term maintainability of the code. They balance purity with pragmatism, considering the business goals and priorities—and they articulate the risk to the business when sacrificing quality/purity for accelerated timelines.&lt;/p&gt;

&lt;p&gt;I believe a software architect should be a mentor, using their experience to teach others how to create the best software they can. This involves in-depth code reviews and pair programming, among other teaching techniques. Good software architects are humble and patient. They don’t berate or belittle their team for not yet grasping concepts that they see clearly. Instead, they use these moments as teaching opportunities.&lt;/p&gt;

&lt;p&gt;Many see coding as formulaic as algebra equations. Software developers are natural problem-solvers, often seeing a code solution based on a formula before fully understanding the problem. Software architecture is different. There is no formula for it. There are recurring patterns seen across problem domains, and Martin Fowler has cataloged many, but his book Patterns of Enterprise Application Architecture cannot be treated as a formula by filling in the blanks and generating the code. It doesn’t work that way.&lt;/p&gt;

&lt;p&gt;Learning to design software from an architectural perspective is an exercise in grokking&lt;sup&gt;&lt;a href="https://en.wikipedia.org/wiki/Grok" rel="noopener noreferrer"&gt;2&lt;/a&gt;&lt;/sup&gt; the problem, taking a Zen-like approach to perceiving its true nature. To do this, you must exercise restraint so you don’t cloud your mind with thoughts of the solution before you fully understand the problem.&lt;/p&gt;

</description>
      <category>software</category>
      <category>architecture</category>
      <category>architect</category>
      <category>leadership</category>
    </item>
  </channel>
</rss>
