{"id":399,"date":"2020-12-21T21:18:00","date_gmt":"2020-12-21T21:18:00","guid":{"rendered":"https:\/\/localwp.com\/?post_type=help&#038;p=399"},"modified":"2023-07-27T16:07:32","modified_gmt":"2023-07-27T16:07:32","slug":"local-and-php-8","status":"publish","type":"help","link":"https:\/\/localwp.com\/help-docs\/advanced\/local-and-php-8\/","title":{"rendered":"Local and PHP 8"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" href=\"https:\/\/localwp.com\/community\/t\/local-beta-5-9-7\/23518\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">Local Beta 5.9.7<\/span><\/strong><\/a> was the first build of Local to include PHP 8 and now, the <a href=\"https:\/\/localwp.com\/releases\/\"><strong><span style=\"text-decoration: underline;\">latest version of Local<\/span><\/strong><\/a> includes it too!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While most things should work with the latest version of WordPress, there are some edge-cases to be aware of. Keep reading for more details!<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-group help-doc-toc\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\">Table of Contents:<\/p>\n\n\n<nav aria-label=\"Table of Contents\" class=\"wp-block-table-of-contents\"><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"#why-should-i-upgrade-to-php-8\">Why Should I Upgrade to PHP 8?<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"#does-php-8-work-with-wordpress\">Does PHP 8 work with WordPress?<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"#local-and-php-8\">Local and PHP 8<\/a><ol><li><a class=\"wp-block-table-of-contents__entry\" href=\"#dont-forget-aka-limitations\">Don&#039;t Forget (aka Limitations)<\/a><\/li><\/ol><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"#this-sounds-like-a-lot-of-work\">This Sounds Like a lot of Work<\/a><\/li><li><a class=\"wp-block-table-of-contents__entry\" href=\"#resources\">Resources<\/a><\/li><\/ol><\/nav>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color\" id=\"why-should-i-upgrade-to-php-8\" style=\"color:#000000\"><strong>Why Should I Upgrade to PHP 8?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a good question, and the process isn&#8217;t easy due to so many breaking changes. The main reason is the significant performance improvements related to the just-in-time compilation. Some benchmark tests show improvements of almost&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.php.net\/releases\/8.0\/en.php\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">3 times as fast<\/span><\/strong><\/a>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Beyond the performance improvements, there are many changes to the language that make it easier to write fast, bug-free code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One specific example is that many PHP notices will now be warnings. While you might initially think this is a bad thing \u2013 the benefit is that these warnings are more informative and allow developers to find and fix issues early in the process!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get a better idea of all the PHP language changes viewed through a WordPress lens, look at the &#8220;Changes in PHP 8&#8221; section of the&nbsp;<a href=\"https:\/\/make.wordpress.org\/core\/2020\/11\/23\/wordpress-and-php-8-0\/\"><strong><span style=\"text-decoration: underline;\">WordPress and PHP 8.0<\/span><\/strong><\/a>&nbsp;post of the core make blog.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color\" id=\"does-php-8-work-with-wordpress\" style=\"color:#000000\"><strong>Does PHP 8 work with WordPress?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Yes! Sort of&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because PHP 8 has several breaking changes, the WordPress core developers have introduced a concept of WordPress being &#8220;<strong>Beta Compatible<\/strong>&#8221; with PHP 8. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This means that the most recent <a rel=\"noreferrer noopener\" href=\"https:\/\/wordpress.org\/news\/category\/releases\/\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">WordPress versions<\/span><\/strong><\/a> (<code>5.6<\/code> and later) are compatible, but given the large ecosystem of Plugins and Themes, &#8220;WordPress&#8221; isn&#8217;t 100% compatible. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Again the&nbsp;<a href=\"https:\/\/make.wordpress.org\/core\/2020\/11\/23\/wordpress-and-php-8-0\/\"><strong><span style=\"text-decoration: underline;\">WordPress and PHP 8.0<\/span><\/strong><\/a>&nbsp;post on the core make blog does a great job of highlighting what being &#8220;PHP 8 Compatible&#8221; means, so definitely take a look!<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color\" id=\"local-and-php-8\" style=\"color:#000000\"><strong>Local and PHP 8<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Okay, so WordPress core&#8217;s compatibility with PHP 8 is in a pretty good state \u2013 how do I test my site to see if it works with this new version of PHP?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since WordPress is only &#8220;Beta Compatible&#8221;, PHP 7 is still the default version used for Preferred environments. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That being said, the latest beta version of Local allows you to select PHP 8 for custom environments. You also can change the PHP version of existing sites from the site details page.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-php-8-custom-environment-1024x702.png\" alt=\"Screenshot showing how to select PHP 8 from the Custom Environment section of creating a new site.\" class=\"wp-image-408\" style=\"width:840px;height:575px\" width=\"840\" height=\"575\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-php-8-custom-environment-1024x702.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-php-8-custom-environment-300x206.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-php-8-custom-environment-768x526.png 768w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-php-8-custom-environment.png 1112w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-content-php-8-site-overview-1024x702.png\" alt=\"Screenshot showing how to change to PHP 8 from the site overview page.\" class=\"wp-image-409\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-content-php-8-site-overview-1024x702.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-content-php-8-site-overview-300x206.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-content-php-8-site-overview-768x526.png 768w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/local-content-php-8-site-overview.png 1112w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color\" id=\"dont-forget-aka-limitations\" style=\"color:#000000\"><strong>Don&#8217;t Forget (aka Limitations)<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">While testing a site under PHP 8, it&#8217;s important to remember a couple of things:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Only the latest version of WordPress will work. This includes working with a site using wp-cli &#8212; you&#8217;ll need to have at least the 5.6 version of WordPress core.<\/li>\n\n\n\n<li>Just because WordPress Core works with PHP 8, doesn&#8217;t mean that all Plugins and Themes will. Many plugins and themes have new versions that support PHP 8, but not all of them. Be sure to update and test!<\/li>\n\n\n\n<li>No ImageMagick. WordPress core has some good fallbacks, so this shouldn&#8217;t stop you from uploading media to WordPress. However, if your plugin or theme has this requirement, you&#8217;ll need to wait until ImageMagick releases a PHP 8 compatible package. See this Github Issue for more info:\n<ul class=\"wp-block-list\">\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/Imagick\/imagick\/issues\/358\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">New release with PHP 8 support?&nbsp;#358<\/span><\/strong><\/a><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Basically, take a backup of your site, update everything to their latest version, and see if anything breaks!<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color\" id=\"this-sounds-like-a-lot-of-work\" style=\"color:#000000\"><strong>This Sounds Like a lot of Work<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;re not wrong that a lot is going on and that PHP 8 breaks a number of things.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re wanting to get a high-level look at what you&#8217;re getting into, one of the best case studies I&#8217;ve seen was published by Yoast, where they reviewed what it took to get&nbsp;<code>yoast.com<\/code>&nbsp;to be compatible with PHP 8:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.yoast.com\/blog\/the-2020-wordpress-and-php-8-compatibility-report\/#h-part-3-yoast-com-case-study\"><strong><span style=\"text-decoration: underline;\">The 2020 WordPress and PHP 8 compatibility report \u2013 Part 3: yoast.com case study<\/span><\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So yeah, if you&#8217;re overwhelmed, you&#8217;re not alone \u2013 but updating to the latest version of PHP 8 doesn&#8217;t have to happen right now. If you&#8217;re not as technical and afraid of breaking things, you can wait a bit before diving in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Users who are more technical or are maintaining plugins or themes, see the resources section for some tools that can help with this process!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Either way, when using Local, it&#8217;s easy to export your site to have a backup. Using that backup, you can import it into as many new PHP 8 environments as you like! Anything you break in these sandboxes can be deleted without breaking things on your live site!<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-color\" id=\"resources\" style=\"color:#000000\"><strong>Resources<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/make.wordpress.org\/core\/2020\/11\/23\/wordpress-and-php-8-0\/\"><strong><span style=\"text-decoration: underline;\">WordPress and PHP 8.0<\/span><\/strong><\/a>\n<ul class=\"wp-block-list\">\n<li>This post on the make blog is a good place to orient yourself, especially viewing the PHP 8 update through a WordPress lens.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>WP Tavern: <a rel=\"noreferrer noopener\" href=\"https:\/\/wptavern.com\/getting-your-wordpress-plugins-and-themes-ready-for-php-8\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">Getting Your WordPress Plugins and Themes Ready for PHP 8<\/span><\/strong><\/a>\n<ul class=\"wp-block-list\">\n<li>Great overview resource with links to additional steps you can take to update code to be compatible with PHP 8.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Yoast: <a href=\"https:\/\/developer.yoast.com\/blog\/the-2020-wordpress-and-php-8-compatibility-report\/#h-part-3-yoast-com-case-study\"><strong><span style=\"text-decoration: underline;\">The 2020 WordPress and PHP 8 compatibility report \u2013 Part 3: yoast.com case study<\/span><\/strong><\/a>\n<ul class=\"wp-block-list\">\n<li>Another great overview resource with a case-study of what happened when upgrading yoast.com to be compatible with PHP 8.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/PHPCompatibility\/PHPCompatibility\" target=\"_blank\"><strong><span style=\"text-decoration: underline;\">PHP Compatibility Coding Standard for PHP CodeSniffer<\/span><\/strong><\/a>\n<ul class=\"wp-block-list\">\n<li>This Github repository is great for initial static analysis of your code.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large is-style-drop-shadow\"><img decoding=\"async\" width=\"1024\" height=\"575\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/php-8-codesniffing-1024x575.png\" alt=\"\" class=\"wp-image-405\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/php-8-codesniffing-1024x575.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/php-8-codesniffing-300x168.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/php-8-codesniffing-768x431.png 768w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/php-8-codesniffing.png 1144w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/community.localwp.com\/c\/support\/5\" target=\"_blank\" rel=\"noreferrer noopener\">Get Community Support<\/a><\/div>\n<\/div>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Local Beta 5.9.7 was the first build of Local to include PHP 8 and now, the latest version of Local includes it too! While most things should work with the latest version of WordPress, there are some edge-cases to be aware of. Keep reading for more details! Table of Contents: Why Should I Upgrade to&#8230;<\/p>\n","protected":false},"author":49,"parent":352,"menu_order":7,"template":"","tags":[43],"helpcategories":[5],"class_list":["post-399","help","type-help","status-publish","hentry","tag-advanced","helpcategories-advanced"],"acf":{"help_keywords":""},"_links":{"self":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc"}],"about":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/types\/help"}],"author":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/users\/49"}],"version-history":[{"count":0,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/399\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/352"}],"wp:attachment":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/media?parent=399"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/tags?post=399"},{"taxonomy":"helpcategories","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/helpcategories?post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}