Paul Carlton

Run SugarCRM 7.x with PHP 7

Discussion created by Paul Carlton on Jan 21, 2016
Latest reply on Aug 6, 2016 by Hiren Darji

This is not a question, this is a discussion to help others quickly get SugarCRM 7.5 (probably all SugarCRM 7.~) to run with PHP 7.


Sugar has a bit of really old code in /include/SugarObject/SugarConfig.php where they are still using the var keyword and still access the variable with $this from static context.  Obviously this now throws an error as $this should only be used in class instantiation context, not static class context.  All you need to do here is change "var $_cached_values" on line 19 to "public static $_cached_values".  In the class, change every instance of "$this->_cached_values" to "self::$_cached_values" and that will get you up and running.


There's one more issue though that will keep you from logging in and that is Elastic Search PHP library.  If you look at Elastic search's website you'll see that in PHP 7, their older library no longer works, which they have documented, because they use a keyword for a class name "Bool" which is now reserved.  You will need to do a global find and replace.  Preferrably you will want a regular expression search and replace because I believe there is BoolOr and BoolAnd and you don't really want to change them.  I guess you could if you do it globally but I think it would be best to keep the code as clean and untouched as possible.  So with a regex replace say in PHPStorm you would use "Elastica\\Filter\\Bool\b" and replace that with "Elastica\\Filter\\BoolFilter" as specified in their docs.  They say to use BoolFilter in the library.  Do one last search for "class Bool" and change that to "class BoolFilter".


I have made these changes on my localhost and I am now able to use SugarCRM 7 across the board although I have not tested everything.  And since it's on my localhost host, Elastic Search is not enabled or running so I have not tested to make sure that Elastic Search is still going.  I would assume that it does because the only thing changed in the code are the class names and everything has been accessed correctly so I'm assuming it will.  If there's anything that I've missed, please let me know!  I would prefer to have SugarCRM on the server run on PHP 7.







Turns out I missed Module Builder which just doesn't want to function. :-/




EDIT 02/11/2015



I was able to get admin surfacing but after a rebuild repair, it breaks completely.  The template file for smarty in the cache/ directory is empty, and when I put "hi" in it, the page would then load with "hi", the rest blank.  So I presume that's where it's breaking, it can't cache a template file that loads up the application.  It now loads a blank page no matter where I'm at.  So if the cache exists, the application works, but if you try and repair rebuild it breaks.  I tried to debug it but without a few more hours of tracing through the code, I wasn't able to get to far.