Note : This is a guide for PS 1.6.x because 1.7 provide a composer.json
The PHP World is full of talentued developers. They create very usefull and powerfull libraries. In PrestaShop, developers often have to reimplement them. Unless use composer !
First, you have to install composer to your system. I don't teach you how to do this, read the doc. Then, in your project root, launch
composer init
The main file for PS is the famous config/config.inc.php
wich define all PS need to work.
So we will be tempted to modify it to add require ../vendor/autoload.php;
. But we don't want to edit this file directly, and add it in our VCS.
And guess what, PrestaShop devs have thought of everything! In config.inc.php, we can found this line:
define('_PS_CUSTOM_CONFIG_FILE_', _PS_CONFIG_DIR_.'settings_custom.inc.php');
...
/* Custom config made by users */
if (is_file(_PS_CUSTOM_CONFIG_FILE_)) {
include_once(_PS_CUSTOM_CONFIG_FILE_);
}
There is a proper way to include a config file.
So create a config/settings_custom.inc.php
file with this inside :
<?php
# Require Autoload from composer
require_once _PS_ROOT_DIR_ . '/vendor/autoload.php';
And you are able to use external libraries. Go on packagist
Now, you can create modules, and use your libraries inside
But the must is to separate your modules in external repos to require them in your PrestaShop Installation.