Sublime Text 3 Error: Warning. PHP 5.6 or newer is required. Please, upgrade your local PHP installation

8.4k views Asked by At

I started getting this error in Sublime Text 3 when saving files:

Warning. PHP 5.6 or newer is required. Please, upgrade your local PHP installation.

I am using Sublime SFTP as well. I am not using local XAMP environment but did install php 5.6 on my local machine (MacOSX) to try and fix the problem. I also reinstalled all packages related to PHP, but the error persists.

9

There are 9 answers

0
hungtd On

You use phpfmt plugin?

To disable the warning, please follow the steps listed below:

  1. Open menu item Sublime text\References\Packages settings\phpfmt\Settings - User
  2. Add content below

{ "php55warning": false }

  1. Reopen Sublime Text 3
2
logic On

Thanks for pointing me to the right direction @hungtd. I tried

"php55warning": false
"php56warning": false
"php55compat": true

but none worked.

The solution I found was this: manually edit phpfmt.py file (Sublime Menu > Browse Packages > phpfmt) and comment out line 230:

# sublime.message_dialog('Warning.\nPHP 5.6 or newer is required.\nPlease, upgrade your local PHP installation.')

No more dialogs on saving :)

0
cow On

I'm use mac don't comment any code, I solved it like this:

  1. Click on menu Sublime text > Preferences > Browse Packages;
  2. Open the file phpfmt-sublime-settings and modify code :

    { "version": 4, "php_bin":"/usr/local/bin/php", "format_on_save":true, "option": "value", "php55compat":true // important }

Reason:

at the file phpfmt.py line 26 is define: s = sublime.load_settings('phpfmt.sublime-settings') will has define php55compat = s.get("php55compat", False), because the waring info condition code:

    if php55compat is False and ('PHP 5.3' in res.decode('utf-8') or 'PHP 5.3' in err.decode('utf-8') or 'PHP 5.4' in res.decode('utf-8') or 'PHP 5.4' in err.decode('utf-8') or 'PHP 5.5' in res.decode('utf-8') or 'PHP 5.5' in err.decode('utf-8')):
    sublime.message_dialog('Warning.\nPHP 5.6 or newer is required.\nPlease, upgrade your local PHP installation.')
    return False
2
Chris Schmitz On

So I ran into this same issue on my computer, but the thing is I most definitely have PHP 5.6 installed:

php -v

After looking at the phpfmt package's default settings I notices a commented out line:

// "php_bin":"/usr/local/bin/php",

It looked like a way of hardcoding the path to your php binary.

I installed php 5.6 via homebrew so I knew the binary was stored in an atypical location, so I:

  • Copied the commented out line
  • Opened my User specific settings for the phpfmt bundle
  • Pasted it in
  • Uncommented the line
  • Got the path to my 5.6 binary via the command which php
  • Pasted that path in to my user settings
  • Saved

No more error and the package still formats per psr standards.

So, just for clarity, my User specific settings for the phpfmt bundle:

User settings

Look like this:

{
    "psr2": true,
    "version": 1,
    "php_bin":"/usr/local/opt/php56/bin/php", // change this path to whatever the path to your local php 5.6 binary 
}
0
lindon fox On

In case none of the other answer work, you can always remove the offending package. For those (like me) who are not sure how to do this, follow these steps (note, this is if you are using Package Control):

  1. Open Command Palette (command + shift + P - on a mac)
  2. Select "Package Control: Remove Package"
  3. Select "phpfmt"
  4. Profit

Of course, this means that you lose all the functionality of the phpfmt plugin.

0
galegomca On

In the file:

C:\Users\YOUR_USERNAME\AppData\Roaming\Sublime Text 3\Packages\phpfmt\phpfmt.py

you may search like

if ('PHP 5.3' in res.decode('utf-8') 
or 'PHP 5.3' in err.decode('utf-8') 
or 'PHP 5.4' in res.decode('utf-8') 
or 'PHP 5.4' in err.decode('utf-8') 
or 'PHP 5.5' in res.decode('utf-8') 
or 'PHP 5.5' in err.decode('utf-8') 
or 'PHP 5.6' in res.decode('utf-8') 
or 'PHP 5.6' in err.decode('utf-8')):

And replace with

if ('PHP 5.3' in res.decode('utf-8') 
or 'PHP 5.3' in err.decode('utf-8') 
or 'PHP 5.4' in res.decode('utf-8') 
or 'PHP 5.4' in err.decode('utf-8') 
or 'PHP 5.5' in res.decode('utf-8') 
or 'PHP 5.5' in err.decode('utf-8') ):
#or 'PHP 5.6' in res.decode('utf-8') or 'PHP 5.6' in err.decode('utf-8')):

or replace your php version.

0
Devang mehta On

Click on Menu > Preferences > Browse Packages

Then you will find "phpfmt" Folder. You will find "phpfmt.py" file in that.

Comment following lines ( Probably Line no: 745,746,747)

if err.decode('utf-8'):
    ret += ("phpfmt (php version) err:\n"+err.decode('utf-8'))
    ret += "\n"

And it Works!

0
HSLM On

I did this and it works for me so I will post it here first of all update your php version using this link :

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

then edit your default settings or the active settings you have by going preferences> package settings > phpfmt

"php_bin":"/usr/local/php5/bin/php",

and it will work

0
grud phunsanit On

you may search like sublime.message_dialog(‘Warning.\nPHP 7.0 or newer is required.\nPlease, upgrade your local PHP installation.\nDebug information:’+s) return False and comment by /* ... */

demo