<?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: Roberto Rivera</title>
    <description>The latest articles on DEV Community by Roberto Rivera (@digitalvillainy).</description>
    <link>https://dev.to/digitalvillainy</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%2F101186%2Fca8d138a-1a36-4414-a37d-ee1f161b3075.jpeg</url>
      <title>DEV Community: Roberto Rivera</title>
      <link>https://dev.to/digitalvillainy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/digitalvillainy"/>
    <language>en</language>
    <item>
      <title>Work and play in PHP 7.4 &amp; PHP 8.0</title>
      <dc:creator>Roberto Rivera</dc:creator>
      <pubDate>Sun, 31 Jan 2021 08:06:06 +0000</pubDate>
      <link>https://dev.to/digitalvillainy/work-and-play-in-php-7-4-php-8-0-25ld</link>
      <guid>https://dev.to/digitalvillainy/work-and-play-in-php-7-4-php-8-0-25ld</guid>
      <description>&lt;p&gt;The classic Dev dilemma, you get comfortable in a language or tool and then there is an update. Do your projects stay with the version that you know? Or do you try and upgrade to a new version as soon as possible? &lt;/p&gt;

&lt;p&gt;I decided to try and find a way to work in 7.4 but experiment with 8.0. Eventually all of my newer projects will adopt the latest versions but I want to be flexible. &lt;/p&gt;

&lt;p&gt;I found working with two different versions of PHP on the same device to be very hard. I tried to find different methods but weren't entirely happy with the results. Therefore, I created a PHP toggle! A Bash script that will allow users to comfortably switch between versions with a quick command. &lt;/p&gt;

&lt;p&gt;Now to preface, I'm totally new to Linux and Bash and realize that there are probably better ways of doing this. But I thought I would share what I did and maybe work shop things. See if this helps other people.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# shellcheck disable=SC2005&lt;/span&gt;
&lt;span class="nv"&gt;modExists&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;php &lt;span class="nt"&gt;-v&lt;/span&gt;:0:7&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;modExists&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;modExists&lt;/span&gt;:0:7&lt;span class="k"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$modExists&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
&lt;span class="s2"&gt;"PHP 8.0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
a2dismod php8.0
a2enmod php7.4
update-alternatives &lt;span class="nt"&gt;--set&lt;/span&gt; php /usr/bin/php7.4&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="s2"&gt;"PHP 7.4"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
a2dismod php7.4
a2enmod php8.0
update-alternatives &lt;span class="nt"&gt;--set&lt;/span&gt; php /usr/bin/php8.0&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;

php &lt;span class="nt"&gt;-v&lt;/span&gt;
systemctl restart apache2
systemctl status apache2

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I've been using this for a while and so far it's been working like a charm. Happy Hacking everyone! I have a gist as well here:&lt;br&gt;
&lt;a href="https://gist.github.com/digitalvillainy/b957c5a856fe05b45da65348f645312f.js"&gt;toggle.sh&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>bash</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
