How to Update PHP in WordPress (Kinsta, DreamHost, & cPanel)

[ad_1] There is a lot of advice on keeping your WordPress themes, plugins, and core files up to date. This helps keep your site in working order. Though, it’s not the only element to focus on. You’ll also want to update PHP in WordPress, to keep the server-side running smooth. Every site has a front end and back end. The back end makes sure your site loads quick, is performant, and keeps malicious users at bay. Your PHP version should be current, for many of the same reasons your site’s files should. In this post, we’ll give you an overview of how WordPress and PHP interact. From there, we’ll show you how to update your PHP in WordPress. How WordPress Uses PHP to Serve Websites Before we get into the bulk of the article, let’s discuss PHP itself. For the unaware, websites run on a ‘stack’. This is a collection of software that helps the site run. For example, WordPress runs using a few different tools and languages: Front end: HTML, CSS. Interactivity: JavaScript, React. Back end: PHP. Server: MySQL. While we won’t be going into the details of everything here in this post, know that PHP is important to WordPress’ functionality. It’s a ‘server-side’ programming language that makes websites dynamic. Take a contact form. The ability to send the information it contains to the server, and store it in the database is crucial for basic operation. The isn’t possible without PHP as part of the WordPress stack. Why You Should Update Your PHP Version in WordPress Given how WordPress uses PHP – it’s inherent in its operation – keeping the PHP version up to date on your server has a lot of benefits. Many of them are the same here as they are for other site elements: You can take advantage of new developments in the language. There is often better performance in the newer version. Security issues found in previous versions will often be patched, making your site stronger and more secure. For a real-world example, take PHP 8. This is the most recent version of PHP, and it’s been adopted by lots of leading web hosts, for a few reasons: PHP 8 has tightened up its error reporting, which helps developers maintain better code. There are new performance features, such as ‘Just In Time’ (JIT) processing. This can be compared to caching, in that PHP tracks often used scripts and optimizes them. There are a lot more benefits, but they’re beyond the scope of this article. Even so, there are some situations that don’t call for an immediate upgrade. Let’s discuss this next. When You Should Update Your PHP Version As per the standard advice for anything relating to your site, updating depends on a few variables. In most situations involving your themes, plugins, and core files, you’ll update as soon as you’re able. In contrast, your PHP version may not warrant an upgrade straight away. For many cases, there are more drawbacks than positives. Here are a few: Some functions have been depreciated in PHP 8, but are still used in lots of WordPress plugins. As such, upgrading could break them (and by extension, your site). In other words, your site and its dependencies may not be compatible with the update. You may find that you don’t need the enhanced functionality of a new PHP version. Your host might not support the newer version of PHP yet, for reasons of security and stability. Again, there are lots more reasons, specific to your own needs and that of your host. In general, unless there’s a huge spotlit reason for not upgrading, you should do so. What’s more, lots of hosts will let you know how to upgrade when the time’s right. They should all have a blog, newsletter, knowledge base article, and more detailing whether an upgrade is possible, and how to do it. How to Check Your Current PHP Version First off, you need to check your current version of PHP before upgrading it. Achieving this depends on your host and current plan. Most custom dashboards will have a specific panel dedicated to PHP management. For example, Kinsta (our review) includes it in your list of sites: In contrast, DreamHost gives you the information after navigating a few subscreens: For cPanel users, your current PHP version can be found in the MultiPHP Manager: Regardless of your host, it should almost always display the current version of PHP used on your site. You may also find that you’re running the latest version of PHP anyway. Lots of hosts will automate this with your permission, such as confirmation through a newsletter, or a dedicated toggle within your control panel. It could also be that you don’t get to update PHP in WordPress just yet. This is often because the host wants to test the functionality first before deploying it to the public. In these cases, there’s not much for you to do. Your host will handle the process, and you can sit back. It’s fair to say that this article is less relevant if you’re on a managed WordPress host. Still, the process is worth knowing as you may want to update PHP in WordPress for reasons specific to you. What You’ll Need Before Updating Your PHP Version The good news is that because updating PHP in WordPress is straightforward, you won’t need too much to get the job done. In fact, there are less than a handful of elements you’ll need in place: Administrator access to your server. The ability to upgrade your PHP version within your hosting panel. Other than this, there are a few preventative measures you can take before pressing on with an update: Make a current, clean backup of your site – in case the worst happens and you have to start from scratch. Update your WordPress site’s core files. Update your site’s themes and plugins. Check the compatibility once again. Once you’re set, you’re ready. The next section will show you

Continue reading

What’s Coming in PHP 8.1

[ad_1] What’s Coming in PHP 8.1 → PHP 8.1 is very much in progress, and is slated to come out in November. While WordPress developers often (and reasonably) don’t use many of the features of PHP 7, nevermind PHP-8-only features, some of these things are at least worst knowing about. Seeing where the language is going (even if you can’t write code that way yet) is always worthwhile. In the article, Brent kicks off with enums, a whole new data-type for PHP. I’ve heard many mixed things about enums in a variety of domains (I think people hate them as a type for a database columns… ) but from his little example I’m immediately excited to start using them. And no doubt (as one must with most programming paradigms) eventually figuring out their disadvantages Anyway, if you’re more than passingly-aware of PHP, probably worth giving this article a quick scan. And if you’re regularly writing PHP, I think a read is wiser. [ad_2] Source link

Continue reading

How To Downgrade Composer, PHP, and NPM

[ad_1] TL;DR: If you’re working on a variety of projects each of which requires different versions of PHP, Composer, and/or NPM you may need to change the version of all or any permutation of any of these utilities. This article outlines what steps need to be taken to downgrade Composer, PHP, or NPM when working on any given project. Downgrade Composer, PHP, and NPM Downgrading Composer 2 to Composer 1 For the last couple of months, I’ve been using Composer 2 with no problem; however, I’ve just had the need to downgrade Composer for a current project. To do this, issue the following command in the terminal: $ sudo composer self-update –1 Usually, this will work. If it’s been a little while since you’ve done anything like this then you may need to update your keys. Verify Keys The terminal commands for updating this are easy enough in terms of guiding you how to do it but having the following URL will be handy. First, grab this URL: https://composer.github.io/pubkeys.html. Then issue the following command: $ composer self-update –update-keys From there, the terminal will prompt you for which key you need to enter. Once done, you should be able to complete the downgrade process. Downgrade PHP I use Homebrew to manage the various installations of PHP that I have. I’ve been working on a project that was using PHP8 but have needed to downgrade it. Assuming you already have the existing package for the version of PHP you want to use, you can use one of the previous installed versions. For example, I have PHP 7.3.26 installed in /usr/local/Cellar/php@7.3 on my local machine. To see which versions you have installed, I do something like this: $ ls /usr/local/Cellar/php* And the outline will return the directories of the versions of PHP I have installed. At the time of this writing, I have: /usr/local/Cellar/php which is 8.0.3 /usr/local/Cellar/php@7.3 which is 7.3.27 To use the older version, I first need to unlink the current version of PHP: $ brew unlink php And then create a link to the previous version: $ brew link php@7.3 –force –overwrite And it’s important to use the directory name (such as php@7.3 that terminal returns above). To verify that this works, you should be able to run $ php -v and see the version that’s currently being run. Downgrade NPM Similar to the previous two items above, I’ve needed to downgrade a package which came as information when running npm i in the terminal. Assuming the warning, error, or notice shows the version that you need then use that as a guide for what version to downgrade. First, identify the current version by running: $ npm -v Then, using the information from the message in the terminal, run the following command: $ npm install -g npm@6.13.4 One done, double-check the version once more using the same command as above and it should match with what you just installed. Not All At Once Obviously, you may not need to change all of these at the same time but one at a time. And that’s not unusual. This post is the result of me working on something from front-end to back-end that required I update the whole environment. Ultimately, upgrade or downgrade only what you need. One doesn’t necessitate the need to update the others. [ad_2] Source link

Continue reading