One of the key part of working on a major version is to review how things are made, to rethink our processes, and to modernize the codebase in order to stay technically relevant. Version 1.7 of PrestaShop is a major step in that direction, as this article will show. Note that most of the information in this article comes from earlier articles published on the Build PrestaShop devblog, which you should visit regularly for the latest news from the development team!
PrestaShop now includes the Symfony framework
The development team has long wanted to rethink the Core architecture of PrestaShop. The main idea has always been to make it more modular, more testable, and of course more robust. Version 18.104.22.168 of PrestaShop was a first go at this idea. But the team quickly found that it wasn’t enough to rewrite our own framework: the best way was to use what the Open Source community provides us with. PrestaShop 1.7 will introduce Symfony2 in its Core codebase. This major release will be a great turn on the technical side of the application, but this change will be negotiated smoothly and over the long term: not everything will change with 1.7. Introducing a framework was decided in order to eventually get rid of the “home-made framework” part of the application, and most notably of its maintenance workload, which consumes too much time and is not our core business features (managing a cart, handling orders, calculating prices and taxes, generating invoices, etc.). Using a proven and popular open-source framework will allow us to focus on our core business code with greater efficiency, while enjoying the stability of a globally recognized framework.
PHP requirements upgraded to version 5.4
Because we’ve always made sure your PrestaShop store could run on a cheap shared hosting plan in a far far away land, we had to support PHP all the way back to version 5.2 – a version that has been unsupported since January 2011. In June 2015, the development team chose to switch the PHP 5.4 as the minimum requirement to run PrestaShop. We could jump all the way to version 5.5 or even 5.6, but those are still supported by very few hosts. Using PHP 5.4 allows development to integrate new tools:
Note that PrestaShop 1.7 is also compatible with PHP 7.
New development standards
The PrestaShop codebase moved from our in-house coding standards to PSR-2 in July 2015. Since then, we chose to integrate the Symfony framework into the codebase. So, what’s more natural than to follow their coding standards? It comes as a complement of the PSR standards (PSR-0,PSR-1,PSR-2 andPSR-4). Some noteworthy rules:
- Use camelCase, not_underscores, for variable names, function names, method names, and arguments names.
- Yoda conditions you should use.
- Add a comma after each array item in a multi-line array, even after the last one.
And because PrestaShop is much more than just PHP code, we adopted coding standards for our other languages:
- CSS & HTML: we have decided to follow the Bootstrap 4 coding standards.
○ Also used for Smarty / Twig code. We created an EditorConfig file to help you! It is located at the root of the PrestaShop repository: you can download it here. It’s particularly useful when having to handle different tab sizes depending on the file type.
New developer documentation
Historically, PrestaShop hosted its documentation on http://doc.prestashop.com, powered by the Atlassian Confluence wiki system. We feel it is not very developer-friendly – you can’t contribute easily (you have to ask for a user account to be created), the design is outdated, too many clicks are needed to reach an information, etc. - so we decided to move to another system for the 1.7 technical documentation. As of today, the legacy documentation website is still online, and the new website basically hosts the 1.7-specific tech doc (themes and modules):
- 1.4-1.7 merchant doc and 1.4-1.6 tech doc: http://doc.prestashop.com
- 1.7 tech doc: http://developers.prestashop.com
Since it’s plain text files, it’s versioned with Git and hosted on GitHub. Is there an easier way for you, as developers, to contribute? :) Please open a pull request to fix or add anything. You can open an issue if you want to request documentation about anything specific. For example: “how to use the new product page hooks”, or “how to use the theme template in a module”.
More on PrestaShop 1.7!