Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
In the /src
folder you’ll find 3 main folders with different purposes:
Context
, Dispatcher
or constants);Core classes belong to the PrestaShop\PrestaShop\Core
namespace.
This is the default destination for any new code, as long as it follows these rules:
Context
, Dispatcher
, etc.Adapter classes belong to the PrestaShop\PrestaShop\Adapter
namespace.
Since Core code cannot depend directly on legacy classes, classes in the Adapter namespace provide Core classes with “bridge” to legacy classes by following the Adapter pattern strategy. Through this pattern, Adapter classes wrap legacy code in a way that implements the interface required by Core.
In time, these interfaces will be reimplemented in “pure” Core code, rendering Adapters unnecessary.
Code in this namespace should follow these rules:
You should create a new file here whenever you have a hard bound with legacy files, and
you can’t refactor it easily. For instance, take a look at PhpParameters
class in “Configuration”: this class doesn’t rely on
Context or specific constants but on the configuration files of PrestaShop legacy framework. As these files are shared by both front and back, we couldn’t manage to refactor it and remove it now.
Bundle classes belong to the PrestaShopBundle
namespace. This folder contains the code composing the application layer, meaning:
Code in this namespace should follow these rules:
Context
, Dispatcher
, etc.Here are some examples of subsystems belonging to PrestaShopBundle:
Here’s a recap for the dependency rules.
Subsystem | Namespace | Can use Core | Can use Adapter | Can use Legacy |
---|---|---|---|---|
Core | PrestaShop\PrestaShop\Core |
Yes | No 1 | No |
Adapter | PrestaShop\PrestaShop\Adapter |
Yes | Yes | Yes |
PrestaShopBundle | PrestaShopBundle |
Yes | Yes | No |
Legacy | (None) | Yes | Yes | Yes |
Core classes SHOULD NOT depend directly on Adapter classes (they SHOULD depend on interfaces instead). ↩︎