Page 1 of 8
OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Tue Jun 08, 2021 6:29 am
by MaxD
Hello, everyone! The long time have passed since I posted here.
I have created OpenCart distribution I'd like to share, that includes awesome performance changes and works with any PHP from 5.4 and higher.
It was really sad to see as PHP requirements raise enormously with each minor update (
I will be glad to hear your feedback.
Link to download -
https://opencart.download/
Frontend demo -
https://demo.opencart.download/
Backend demo -
https://demo.opencart.download/admin/
Here is more detailed description:
About this distribution
This is official OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support, simplified install, improved performance (
two times faster) and long-awaited fixes. It retains full compatibility with all OpenCart extensions.
Performance Tuned
- Optimized TWIG engine with speed comparable to old TPL approach, that may gain up to 70 ms with heavy template, also it is compatible with PHP 5.4
- Optimized events system, up to 20 ms gain
For the test two fresh installations was taken - this one and official OpenCart. Page generation time was measured (without compression and output). Tests show following results:
Homepage:
60 ms vs
140 ms
Admin Dashboard:
40 ms vs
70 ms
After that Journal 3 template was installed with demo data.
Journal 3 Homepage:
230 ms vs
520 ms
Simplified Installation
- No need to rename config-dist.php
- No need to delete install directory
- No need to move storage folder
- No need to rename .htaccess
Visual Changes
- Button captions added to all buttons at admin (without template files modification)
- Default theme look changed to be more contemporary (just with CSS edit)
- .00 tail removed in prices for better readability (so $45.00 becomes $45)
Fixes
- GZIP compression turned on for admin and frontend (do you know it doesn't work at all in official OpenCart 3.0.3.7?)
- .htaccess files added to image and view/theme folders to impose proper compression and caching headers
- index.php?route=common/home tail removed from homepage links
- removed token warning at admin login screen
- OCMod log is cleared on modifications refresh
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Tue Jun 08, 2021 9:14 am
by EvolveWebHosting
One question:
WHY would you spend time creating a version that works on outdated and slower PHP versions?
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Tue Jun 08, 2021 9:17 pm
by MaxD
It was not intentionally )
I just tried to speed-up OpenCart TWIG part and that lead to creation of TWIX (remastered TWIG engine that consists just of 2 .php files, thats why it's called TWIX). The side effect was that TWIX turned out to be PHP 5.4 compatible. OpenCart itself is PHP 5.4 compatible as well, that is TWIG engine that raised the bar up to PHP 7.4.
I admit that PHP 5 is slow and outdated. But it is quite annoying when I can not install Opencart without tricks at my localhost or VPS because it is PHP 7.2 there.
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Wed Jun 09, 2021 12:07 am
by EvolveWebHosting
MaxD wrote: ↑Tue Jun 08, 2021 9:17 pm
It was not intentionally )
I just tried to speed-up OpenCart TWIG part and that lead to creation of TWIX (remastered TWIG engine that consists just of 2 .php files, thats why it's called TWIX). The side effect was that TWIX turned out to be PHP 5.4 compatible. OpenCart itself is PHP 5.4 compatible as well, that is TWIG engine that raised the bar up to PHP 7.4.
I admit that PHP 5 is slow and outdated. But it is quite annoying when I can not install Opencart without tricks at my localhost or VPS because it is PHP 7.2 there.
If you have a VPS, you should be able to install any available version of PHP. WHM for example, you can install up to 8.0
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Wed Jun 09, 2021 6:07 pm
by khnaz35
MaxD wrote: ↑Tue Jun 08, 2021 6:29 am
Hello, everyone! The long time have passed since I posted here.
I have created OpenCart distribution I'd like to share, that includes awesome performance changes and works with any PHP from 5.4 and higher.
It was really sad to see as PHP requirements raise enormously with each minor update (
I will be glad to hear your feedback.
Link to download -
https://opencart.download/
Frontend demo -
https://demo.opencart.download/
Backend demo -
https://demo.opencart.download/admin/
Here is more detailed description:
About this distribution
This is official OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support, simplified install, improved performance and long-awaited fixes. It retains full compatibility with all OpenCart extensions.
Performance Tuned
- Optimized TWIG engine with speed comparable to old TPL approach, that may gain up to 70 ms with heavy template, also it is compatible with PHP 5.4
- Optimized events system, up to 20 ms gain
Simplified Installation
- No need to rename config-dist.php
- No need to delete install directory
- No need to move storage folder
- No need to rename .htaccess
Visual Changes
- Button captions added to all buttons at admin (without template files modification)
- Default theme look changed to be more contemporary (just with CSS edit)
- .00 tail removed in prices for better readability (so $45.00 becomes $45)
Fixes
- GZIP compression turned on for admin and frontend (do you know it doesn't work at all in official OpenCart 3.0.3.7?)
- .htaccess files added to image and view/theme folders to impose proper compression and caching headers
- index.php?route=common/home tail removed from homepage links
- removed token warning at admin login screen
- OCMod log is cleared on modifications refresh
Welcome Back to Forum Max. Hope you are doing good during this challenging time.
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Wed Jun 09, 2021 7:24 pm
by JNeuhoff
Quite impressive what you did to Twig with your own Twix.
Just one small error in the developer settings, see attached screenshot, when enabling or disabling theme caching.
Re: OpenCart 3.0.3.7 with PHP 5.4 to PHP 8 support
Posted: Thu Jun 10, 2021 12:28 am
by MaxD
JNeuhoff, thank you for good words!
Everything is ok there, the error happens because that operation is not allowed in permissions. Any modification is prohibited for that demo account.
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 10, 2021 9:33 am
by MaxD
I have added speed measurements results )
For the test two fresh installations was taken - this one and official OpenCart. Page generation time was measured (without compression and output). Tests show following results:
Homepage: 60 ms vs 140 ms
Admin Dashboard: 40 ms vs 70 ms
After that Journal 3 template was installed with demo data.
Journal 3 Homepage: 230 ms vs 520 ms
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Fri Jun 11, 2021 1:02 am
by khnaz35
Got a PHP warning:
2021-06-09 7:06:38 - PHP Notice: Array to string conversion in /home/u496403829/domains/demo.opencart.download/public_html/system/library/template/twix_compile.php(454) : eval()'d code on line 76
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Fri Jun 11, 2021 11:34 am
by normdouglas
This is very interesting and exciting
I'm about to try "upgrading" an existing sandboxed OC3 site.
Question... are there any DB mods as part of this release?
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Fri Jun 11, 2021 11:54 am
by MaxD
Nope, there is no any DB mods. To upgrade just overwrite all files except both config.php
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 1:01 am
by Paul.B
When trying the Basel template.
[16-Jun-2021 16:59:13 UTC] PHP Parse error: syntax error, unexpected '-', expecting '{' in /home/XXXXXXXX/public_html/system/library/template/twix_compile.php(454) : eval()'d code on line 4
[16-Jun-2021 16:59:13 UTC] PHP Fatal error: Class 'basel_template_common_mobile-nav' not found in /home/XXXXXXXX/public_html/system/library/template/twix_compile.php on line 460
The above can be quick fixed with
Code: Select all
$cls = str_replace('-', '_', $cls);
Also in checkout:
<b>Notice</b>: Uninitialized string offset: 1 in <b>/home/XXXXXXXX/public_html/system/library/template/twix_compile.php(455) : eval()'d code</b> on line <b>419</b>
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 2:04 am
by LVL91
Thank you very much for your contribution MaxD!
I had to test this myself and I am now starting to explore a few or your changes in the code. I compared the difference in processing time using hrtime around the changes you made in catalog\controller\event\language.php.
I modified this file with your changes with a if/else for the OC default code and your code. I also had to add the set_all() function for this in the language library.
Your simple, yet smart, changes seems to be an improvement of about 1000% for the changes (testing the home page). After a lot of tests on the same setup I measured a performance gain of about 3ms just for this simple change. The OC default code processes in as low as 3.4ms, while your code could process this in as little as 0.36ms. (please take note: the noted times are just for functions that have been changed in the file mentioned above)
I haven't even started using your "Twix" or any of the other changes, but I have to say I am impressed already...
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 2:50 am
by MaxD
LVL91, glad to hear that! Also you might be interested in checking my events optimization, it is plain replacement of system/engine/event.php - and biggest performance gain.
Unfortunately, Twix doesn't work with some tricky templates, I am fixing the cases on reports.
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 4:38 am
by MaxD
The above-mentioned issues are fixed and distribution updated.
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 6:11 am
by LVL91
MaxD wrote: ↑Thu Jun 17, 2021 2:50 am
LVL91, glad to hear that! Also you might be interested in checking my events optimization, it is plain replacement of
system/engine/event.php - and biggest performance gain.
Unfortunately, Twix doesn't work with some tricky templates, I am fixing the cases on reports.
Well I did my testing again and you certainly didn't lie about this! I used hrtime again for this file at the beginning and the end:
catalog/controller/common/home.php
Just to check the total time it takes to generate everything. OC default needed a minimum of 260ms in this part of the code while your substitution of
system/engine/event.php does the same in as low as 199ms, just below 200ms! That's basically a guarenteed 60ms increase for the homepage! (in my case at least)
Have you thought about releasing this as a separate OCMOD without the visual changes, but with just the performance-related parts?
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 10:43 pm
by MaxD
LVL91, I don't know yet if I will post this as OCMod. Still waiting for some reaction from people if they need it at all )
Meanwhile all this optimizations are included into my
OpenCart Lightning accelerator.
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Thu Jun 17, 2021 11:00 pm
by khnaz35
Well Max, I have downloaded this version and want to try but still couldn't got a chance yet.
Definitely love the idea for speed and performance specially with Journal 3 theme.
That's beast need to be beat for speed and performance.
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Fri Jun 18, 2021 10:38 am
by Cue4cheap
MaxD wrote: ↑Thu Jun 17, 2021 10:43 pm
LVL91, I don't know yet if I will post this as OCMod. Still waiting for some reaction from people if they need it at all )
Meanwhile all this optimizations are included into my
OpenCart Lightning accelerator.
Would this be safe to try on OC 2.3.0.2 online store? (I don't normally do that but I just deleted all my test stores).
Mike
Re: OpenCart 3.0.3.7 2x faster and with PHP 5.4 to PHP 8 support
Posted: Fri Jun 18, 2021 10:51 am
by MaxD
If that store is live with non-stop customers traffic I'd recommend checking at test site first. But it's safe in general.