<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raj KB on Medium]]></title>
        <description><![CDATA[Stories by Raj KB on Medium]]></description>
        <link>https://medium.com/@magepsycho?source=rss-d0bfb6e2014f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xrEKot5Y9skpZ1Sz6YhpJQ.jpeg</url>
            <title>Stories by Raj KB on Medium</title>
            <link>https://medium.com/@magepsycho?source=rss-d0bfb6e2014f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 01 Jun 2026 20:07:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@magepsycho/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[How to Install Multiple Versions of PHP on Ubuntu?]]></title>
            <link>https://magepsycho.medium.com/how-to-install-multiple-versions-of-php-on-ubuntu-e3b44c213215?source=rss-d0bfb6e2014f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3b44c213215</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[magento]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Raj KB]]></dc:creator>
            <pubDate>Fri, 18 Jun 2021 17:32:00 GMT</pubDate>
            <atom:updated>2021-06-18T17:32:00.460Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RcD5WhN5DQhxbsDPfCB-g.png" /></figure><p>There are many tools like Docker, Vagrant, VirtualBox, etc. that gives you the power to achieve the multiple versions of PHP in your system. But I want to stay away as much as possible from third-party tools and try to leverage the native as much as I can.</p><p>So want to learn how to install multiple versions of PHP on the Ubuntu system? Okay, that’s great.</p><p>Let’s assume, you have<br>* OS: Ubuntu 16.04<br>* PHP: 7.1 (PHP-FPM)<br>* Nginx: 1.10</p><p>And want to install PHP 7.2</p><h3>Install PHP 7.2</h3><p>Run the following commands to update the PHP repository &amp; the Ubuntu system</p><pre>sudo apt install software-properties-common<br>sudo add-apt-repository ppa:ondrej/php<br>sudo apt update</pre><p>Now you are able to install the new version of PHP</p><pre>sudo apt install -y php7.2-fpm<br>sudo apt install -y php7.2-dev<br>php -v</pre><p>If php -v still pointing to the old PHP version, then run the following command</p><pre>sudo update-alternatives --set php /usr/bin/php7.2</pre><h3>Install PHP 7.2 Modules</h3><p>You may need some additional PHP modules in order for PHP to work with your applications.<br>You can install the most commonly needed modules especially required for Magento 2 with:</p><pre>sudo apt install php7.2-mysql php7.2-bcmath php7.2-curl php7.2-xml php7.2-gd php7.2-intl php7.2-mcrypt php7.2-mbstring php7.2-soap php7.2-zip</pre><p>To check installed PHP modules:</p><pre>php -m | grep -E ‘bcmath|ctype|curl|dom|gd|hash|iconv|intl|json|mbstring|mcrypt|openssl|pdo|soap|spl|xml|xsl|zip’</pre><p>To search the PHP module:</p><pre>sudo apt-cache search php7.2</pre><p>Now, you have a new PHP 7.2 version and the required modules installed. Similarly, you can install PHP 7.3, 7.4, 8.0 &amp; so on and its related modules.</p><p>Now a big question is: <strong>How to use a specific PHP version as per application?</strong></p><p>Before that, we should know how PHP is used.<br>PHP can be used as a CLI or web server module (mod_php, CGI, FPM).</p><h3>Switching PHP CLI Version</h3><p>PHP’s php command is linked to /usr/bin/php, which is symlinked to /etc/alternatives/php, which again is symlinked to actual PHP, for example /usr/bin/php7.2.<br>So here lies the logic of switching PHP CLI versions.</p><p>By default, the PHP installation changes the CLI version to the new one.<br>In case if you want to switch to a specific version, say PHP 7.2, you can use the update-alternatives command</p><pre>sudo update-alternatives — set php /usr/bin/php7.2<br>php -v</pre><p>You can find the list of PHP executables with</p><pre>ll /usr/bin | grep php</pre><p><em>You might need to run </em><em>update-alternatives to set the required PHP version if you are running </em><em>composer commands or any CLI PHP script.</em></p><h3>Switching PHP Web Server Version</h3><p>As you probably know, Nginx runs PHP code via PHP-FPM, which listens on a Unix socket.<br>And that makes it easier to switch the PHP version in the Nginx’s server block.</p><p>If you want to point any application, say Magento 2 running on Nginx with PHP 7.2, you can simply change the value of the fastcgi_pass directive as:<br>You can find the list of PHP executables with</p><pre>fastcgi_pass unix:/run/php/php7.2-fpm.sock</pre><p>To find the list of Unix sockets for PHP-FPM</p><pre>ll /run/php | grep sock</pre><p>In order to verify the PHP version for Web SAPI, you can use phpinfo() in your .php file.</p><h3>Conclusion</h3><p>Some people might want to use Docker, Vagrant based solution for this. It’s Okay.</p><p>For me, I always prefer a native system without depending on third-party solutions. This minimizes the overhead and latency problem and hence makes the application development easier and faster.</p><p>Above you read, how easily you can change the PHP CLI and Web SAPI version. For CLI-based, you might have to run the update-alternatives command on demand. But for Web applications, once the required PHP version is set, they will work independently on specific PHP versions.</p><p>Please comment below if you have any better solution for handling multiple PHP versions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3b44c213215" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tinkerwell: Tinker with your local/remote PHP & Magento 2 Code]]></title>
            <link>https://magepsycho.medium.com/tinkerwell-tinker-with-your-local-remote-php-magento-2-code-2598c32ca95e?source=rss-d0bfb6e2014f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2598c32ca95e</guid>
            <category><![CDATA[magento]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Raj KB]]></dc:creator>
            <pubDate>Mon, 20 Apr 2020 04:34:23 GMT</pubDate>
            <atom:updated>2021-06-21T17:03:22.234Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snZr5Ipp06bulCOUH6ayDA.png" /></figure><p>I was always looking for a <a href="https://blog.magepsycho.com/sandbox-script-quick-testing-magento2/">quick playground for testing/debugging</a> any PHP application esp. for Magento 2.</p><p>Luckily, I got to know about Tinkerwell App in some Twitter feed and thought of giving it a try.</p><h3>Michiel Gerritsen on Twitter: &quot;.@tinkerwellapp + Magento 2 is a great combo. It allows me to SSH into the server and execute code on the real order object for example. In this case, i was debugging why a credit memo couldn&#39;t get created for this order. pic.twitter.com/msS5Enx4Oc / Twitter&quot;</h3><p>@tinkerwellapp + Magento 2 is a great combo. It allows me to SSH into the server and execute code on the real order object for example. In this case, i was debugging why a credit memo couldn&#39;t get created for this order. pic.twitter.com/msS5Enx4Oc</p><p>If you don’t know about the Tinerwell app</p><blockquote><a href="https://tinkerwell.app/"><em>Tinkerwell</em></a><em> is the magical code editor that runs your code within local and remote PHP applications. In other words, it’s a </em><a href="https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop"><em>RELP</em></a><em>(read-eval-print loop) for PHP.</em></blockquote><p>Though there are some tools like</p><p>But the main advantage of the Tinkerwell app over others is that it can tinker locally and also remotely(via SSH). Also, it has official IDE plugins so that you can run code directly from your favorite code editor(VSCode, Sublime Text 3, and PhpStorm).</p><h3>Installation</h3><p><a href="https://tinkerwell.app/">Tinkerwell</a> is a commercial app that only costs around <em>15 USD</em> and really worth it.</p><p>After purchasing, you will get an email with a link to download the app along with the license key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L7gyv4wnGB0EiUze.png" /></figure><p>After downloading you can simply install the installer file and configure the License Key, so nothing fancy about it.</p><h3>Configuring for Magento 2</h3><p>Currently(as the time of writing), the major PHP applications supported by Tinkerwell app are:</p><p>The full list can be found at — <a href="https://github.com/tinkerwellapp/drivers">https://github.com/tinkerwellapp/drivers</a></p><p><em>Tinkerwell “drivers” determine how the application should be bootstrapped — and can even provide variables that should be available automatically.</em></p><p>Since Magento 2 is supported by default, you just need to set the working directory in local or remote.</p><h3>Tinkering with Magento 2 Locally</h3><p>Open the app and click on the folder icon (1) and set your local Magento 2 working directory(2). That’s it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2S4P3f7iZp0fZPZX.png" /></figure><p>Now, you can run/debug any Magento 2 code (core &amp; custom) with the real-time preview on the right pane. For example, it may look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fZPTj9gVIG3ftS9j.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0yghUP42ZYPQN3VE.png" /></figure><h4>Troubleshooting</h4><p><strong>Problem</strong>: If you are getting an error</p><blockquote><em>Zend_Db_Adapter_Exception with message ‘SQLSTATE[HY000] [2002] No such file or directory’</em></blockquote><p><strong>Solution</strong>: Just replace ‘localhost’ by the IP address(127.0.0.1) for the DB host in the file app/etc/env.php</p><h3>Tinkering with Magento 2 Remotely (via SSH)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ygn2Q0rUYF6BEFva.png" /></figure><p>For remote interactive debugging, you can connect via Action (1) &gt; Connect Via SSH. You will see a similar popup as below:</p><p>Just fill up the SSH login details and connect(2). Now you are able to able to run the code remotely.</p><h3>Conclusion</h3><p>Though there are some alternatives, Tinkerwell works quite well locally and remotely for testing out any PHP code (not only limited to Laravel, Magento 2 or other PHP frameworks). <br> It’s really quite helpful in quick testing/debugging any PHP code and saves a lot of time.</p><p><em>You might be interested in following the Twitter discussion</em></p><h3>🛒 Magento 2 Extensions 🚀 on Twitter: &quot;Question: How do you debug smartly in M2 production server?Please share your views!@magento @MageOverflow @MagentoMP @max_pronko @markshust @mrloo @VinaiKopp @LBajsarowicz @PeterJaap / Twitter&quot;</h3><p>Question: How do you debug smartly in M2 production server?Please share your views!@magento @MageOverflow @MagentoMP @max_pronko @markshust @mrloo @VinaiKopp @LBajsarowicz @PeterJaap</p><p>Happy tinkering with PHP!</p><p><em>Originally published at </em><a href="https://blog.magepsycho.com/tinkerwell-tinker-with-your-local-remote-php-magento-2-code/"><em>https://blog.magepsycho.com</em></a><em> on April 20, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2598c32ca95e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>