A lot of the time I don’t know what type of server my clients will have before I begin to develop the theme. Even though the contract says minimum requirement for a server is PHP 5.4, this advice is often ignored and it is difficult to enforce once the client has gone off and already purchased some shared hosting for a year that won’t let them upgrade anything.
I have a few projects coming up and I want to start using Sage. Is there a way to edit the theme so that it will work without the minimum PHP 5.4, or will I just have to keep on using Roots?
If you have a client that is
- Not adhering to contract
- Using random bubba server
Sage is the least of your worries.
The fact is: even PHP 5.4 will soon be unsupported. It is your duty as a knowledgeable solution provider to make sure your project is on a secure and supported version. That’s why they pay you the big bucks. http://php.net/supported-versions.php
Technically - you could re-write all of Sage to be more compatible with older version of PHP (no namespaces, short array syntax, etc) but that would take tons of time and you still have the problems @austin so expertly mentioned above.
One thing I would recommend is to save yourself time and headache and find a host (or a set of hosts) that you can consistently recommend in your contracts based on price point.
Many hosts have an affiliate program, and if you add those links in the contract you can even get a generous kickback just for recommending!
Thanks for the suggestions.
This is the fun of working as a developer in China. I deal with horrors no contemporary developer should ever have to encounter on a daily basis.
Looks like my best option will be to work with two versions of the theme!
I think we are making assumptions that everyone uses Roots based on Freelance.
This however is not the case, Roots is getting a big spotlight when it comes to government contractors wanting to use WordPress for government use. That being Drupal 8 is never coming out, so many CMS contractors are jumping ship to Wordpress.
Chances are they are only allowed to use Red Hat as their OS. And Red Hat 6 only allows PHP 5.3 from the regular RHEL repos. PHP 5.4 comes standard on Red Hat 7, but getting a gov agency to update a whole OS that hasn’t been “reviewed” yet is an annoying process.
Its an issue of old IT guys that run the IT policies being unable to allow 3rd party server level repositories or apps without going through an approval process. Getting PHP 5.4 on RHEL 6 is impossible due to the fact you need to use the remi-repo which is 3rd party.
While I think a good amount of Roots users are freelance, I was not making that assumption.
Like I mentioned, there are ways to get around the server not being able to run 5.4, but I don’t think the Roots team wants to be held back by those constraints.
Along with what Julien already pointed out, Roots 7 will always be available on Github.
While many of us who do freelance can sympathize with hosting being held back to 5.3 or lower, as it’s still a battle with many popular hosts, it’s not something that we wish to continue to support. Especially when you look at how long PHP 5.2 has been deprecated, and now 5.3 as well. 5.4 will be deprecated later this year.
If you truly are forced to support a specific version of PHP, then by all means you can do that. Sage is a starter theme for you to modify as you need. If you need PHP 5.3, then all you really would need to modify is short array syntax and possibly short echo, depending on your server config. Namespaces and anonymous functions will function correctly.
It’s worth noting that some of the internally developed GSA repositories have a self-imposed requirement of php 5.4.
It’s also easy enough to remove the short syntax arrays in under an hour. The alternative is to apply the Sage gulpfile to Roots 7 to benefit from the workflow related improvements in Sage.
Sorry if this sounds harsh, but one of the reason why I really like this project is because it does not wallow behind in the backwards compatible world of WordPress/PHP requirements. As was pointed out, support for PHP 5.4 is rapidly approaching an end, and continuing to wait on WP, hosts, plugin, and theme developers to get out of the dark ages on updating PHP and MySQL is unacceptable, both from a security and an innovation standpoint.
This project serves, when necessary, to breakout of the WP box. And that is to be commended. You cannot innovate if your primary focus is on just staying relevant. If you don’t believe that, ask the good folks at Microsoft.
Why can’t you compile from source?
Sorry to bump this old conversation, but I found myself in this unfortunate situation today. Without boring you with all the details, I had to downgrade Sage 8.2.1 to be compatible with a 5.3.x GoDaddy server.
I love working with PHPStorm, but today it was definitely my best friend.
Here’s the steps I took - -
- Set up local clone of the project in an environment running PHP 5.3
- Set the PHP Storm projects language level to PHP 5.3
- Set up a code inspection profile with just the PHP Language Level task.
- Right click and run the inspection on your project folder/s.
- Edit the files PHPStorm gives back.
- Do a project wide find/replace for short echo (find:
<?= replace with:
The Language Level inspection task :
Checks that language features used in the source code correspond the selected language level. (i.e. traits can be used only in PHP 5.x). Desired language level is set in the project configuration (Project Settings | PHP).
Basically, because the interpreter is set to 5.3 it just looks for any instances of code that aren’t compatible with the specified PHP version. Really handy and it pointed out every instance of short array syntax in the project.
Aside from that, I had to change one instance of array dereferencing in assets.php, line 62
return $dist_path . $directory . $manifest->get()[$file];
$tmp = get();
return $dist_path . $directory . $manifest->$tmp[$file];
Most of the time I spent today was fighting with some random vagrant box I found that was preloaded with PHP 5.3. I stopped using MAMP a while back, but at the end of the day I set a copy of the site up on a MAMP instance and got everything done pretty quickly.
Sorry again for the nerco-bump, I just thought this might help any other unfortunate souls who find themselves in the position of having to support an ancient PHP version.
That’s also why it’s good to get hosting information early. Not necessarily so that you can support PHP 5.3, but so you can have that conversation with the client early and more calmly, rather than on launch day when everyone is high stress
No doubt man, it was definitely a misstep on our part. Lesson learned!
FYI the new GoDaddy WordPress hosting does support Sage.
To bad it’s doesn’t support SVGs (not joking), caches assets randomly and hangs onto them even when you flush the cache, installs bloatware plugins, and has the most silly support crew in the universe
What did you learn?
Answer: Don’t use Godaddy
GoDaddy hosting is a cesspool. It’s just an afterthought upsell. Don’t let your clients get suckered into paying for that garbage.
Yeah, I hear you. Wed never suggest it, but some clients come in the door with GoDaddy. We move them when we can, but it’s not always an option.