LogoLogo
Homepage
  • Documentations for PrestaShop 1.5
  • English documentation 1.5
    • About PrestaShop 1.5
    • New features in PrestaShop 1.5
    • Getting Started
      • What you need to get started
      • Installing PrestaShop
      • Installing PrestaShop using the command line
      • Updating & Uninstalling
      • Misc. information
    • Updating PrestaShop
      • Automatic update
      • Manual update
      • Making and restoring your own backup
      • In case of issues
    • User Guide
      • Training
      • Customizing your shop
      • Browsing the front-office
      • Connecting to the PrestaShop back-office
      • First steps with PrestaShop 1.5
      • Adding Products and Product Categories
      • A Look Inside the Catalog
      • Managing Orders
      • Managing Customers
      • Creating Price Rules and Vouchers
      • Managing Shipping
      • Understanding Local Settings
      • Managing Modules and Themes
      • Making the Native Modules Work
      • Understanding the Preferences
      • Understanding the Advanced Parameters
      • Administering the Back-Office
      • Understanding Statistics
      • Advanced Stock Management
      • Managing Multiple Shops
    • Developer Guide
      • Developer tutorials
        • Using the PrestaShop Web Service
          • Webservice one-page documentation
          • Chapter 1 - Creating Access to Back Office
          • Chapter 2 - Discovery - Testing access to the web service with the browser
          • Chapter 3 - First steps - Access the Web service and list client
          • Chapter 4 - Retrieve Data - Retrieving a Client
          • Chapter 5 - Modification - Update client
          • Chapter 6 - Creation - Remote Online Form
          • Chapter 7 - Removal - Remove customer accounts from the database
          • Chapter 8 - Advanced Use
          • Chapter 9 - Image management
          • Chapter 10 - Price management
          • Cheat-sheet - Concepts outlined in this tutorial
          • Web service reference
        • Helpers
          • HelperForm
          • HelperOptions
          • HelperList
          • Using helpers to overload a back-office template
        • New Developers Features In PrestaShop 1.5
        • Using the Context Object
        • DB class best practices
        • Public and overloadable methods
        • Overriding default behaviors
        • Using addJquery(), addJqueryPlugin() and addJqueryUI()
        • Handling special characters in links
        • Auto-updating modules
        • Front-Office Controllers
        • Controllers correspondence table
        • Specifics of multistore module development
        • Developer tips and tricks
        • PrestaShop's developer tools
        • Using the backward compatibility toolkit
      • Fundamentals
      • Coding Standards
      • Setting up your local development environment
      • Diving into PrestaShop Core development
      • Creating a PrestaShop module
      • Creating a front-office module
      • Creating a module with both front-end and back-end controllers
      • Hooks in PrestaShop 1.5
      • Translations in PrestaShop 1.5
      • How to use the Forge to contribute to PrestaShop
      • How to write a commit message
      • Contributing code to PrestaShop
    • Designer Guide
      • Theme development fundamentals
      • Integrating content in a page using hooks
      • Characteristics of a front-office theme
      • Characteristics of a back-office theme
      • Creating your own theme
      • Theme templates and Smarty
      • Using jQuery and Ajax
      • Best practices
      • Designer tutorials
        • Changes in version 1.5 which impact theme development
        • Changing a 1.4 theme to support gift products
        • Implementing layered navigation in a theme
    • System Administrator Guide
    • Merchant's Guide
      • Our advices
      • Sample price rules
    • FAQ
      • Using PrestaShop with WordPress
    • Troubleshooting
  • Documentation française 1.5
    • À propos de PrestaShop 1.5
    • Nouveautés de PrestaShop 1.5
    • Guide de démarrage
      • Ce dont vous avez besoin
      • Installer PrestaShop
      • Installer PrestaShop en ligne de commande
      • Mettre PrestaShop à jour
      • Informations diverses
    • Guide de mise à jour
      • Mise à jour automatique
      • Mise à jour manuelle
      • Faire une sauvegarde et la restaurer
      • En cas de problème
    • Guide de l'utilisateur
      • Formations
      • Personnaliser votre boutique
      • Parcourir le front-office
      • Se connecter au back-office de Prestashop
      • Premiers pas avec PrestaShop 1.5
      • Ajouter des produits et des catégories de produits
      • Un aperçu du catalogue
      • Gérer les commandes
      • Gérer les clients
      • Mettre en place des promotions
      • Gérer les transporteurs
      • Comprendre les réglages locaux
      • Gérer les modules et les thèmes
      • Configurer les modules natifs
      • Comprendre les préférences
      • Comprendre les paramètres avancés
      • Administrer le back-office
      • Comprendre les statistiques
      • Gestion avancée des stocks
      • Gérer plusieurs boutiques
    • Guide du développeur
      • Fondamentaux
      • Norme de développement
      • Mettre en place votre environnement de développement
      • Plonger dans le développement PrestaShop
      • Créer un module PrestaShop
      • Les hooks de PrestaShop 1.5
      • Les traductions dans PrestaShop 1.5
      • Comment utiliser la Forge pour contribuer à PrestaShop
      • Comment écrire un descriptif de modification
    • Guide de l'intégrateur
      • Fondamentaux de la création de thème
      • Intégrer du contenu dans une page à l'aide de hooks
      • Caractéristiques d'un thème front-office
      • Caractéristiques d'un thème back-office
      • Template de thème et Smarty
      • Utiliser jQuery et Ajax
      • Bonnes pratiques
    • Guide de l'administrateur système
    • Guide du vendeur
      • Exemples de promotions
      • Nos bons conseils
    • Questions fréquentes
    • Dépannage
  • Documentación española 1.5
    • Acerca de PrestaShop 1.5
    • Introducción
      • Lo que necesita para empezar
    • Guía del usuario
      • Formación
      • Personalización de su tienda
      • Exploración del front-office
      • Conexión al back-office de PrestaShop
      • Primeros pasos con PrestaShop 1.5
      • Añadir productos y categorías de productos
      • Una mirada interna al catálogo
      • Gestionar pedidos
      • Gestionar clientes
      • Crear reglas de precios y cupones
      • Gestionar el transporte
      • Comprender la Configuración Local
      • Gestionar módulos y temas
      • Configurar los Módulos Nativos
      • Comprender las Preferencias
      • Comprender los Parámetros avanzados
      • Administrar el Back-Office
      • Comprender las estadísticas
      • Gestión avanzada de stock
      • Gestionar varias tiendas
    • Guía del Desarrollador
      • Tutoriales para Desarrolladores
        • Uso del Web Service de Prestashop
          • Capítulo 1 - Creación de acceso al Back Office
  • Документация на русском языке 1.5
    • Информация о PrestaShop 1.5
    • Новые функции в PrestaShop 1.5
    • Приступая к работе
      • Что нужно чтобы приступить к работе
      • Установка PrestaShop
      • Установка PrestaShop при помощи командной строки
      • Обновление и удаление PrestaShop
      • Прочая информация
    • Руководство пользователя
      • Обучение
      • Настройка вашего магазина
      • Изучение публичной части сайта
      • Бэк-офис PrestaShop
      • Первые шаги в PrestaShop 1.5
      • Добавление товаров и товарных категорий
      • Внутри каталога
      • Управление заказами
      • Работа с клиентами
      • Создание правил ценообразования корзины и ваучеров
      • Управление доставкой
      • Ориентация в локальных настройках
      • Управление модулями и темами
      • Настойка встроенных модулей
      • Ориентация в настройках
      • Ориентация в расширенных параметрах
      • Администрирование Back-Office
      • Ориентация в статистике
      • Расширенное управление запасами
      • Управление мультимагазином
Powered by GitBook
On this page
  • Setting up your local development environment
  • Installing PrestaShop 1.5 locally
  • Configuring PrestaShop

Was this helpful?

  1. English documentation 1.5
  2. Developer Guide

Setting up your local development environment

PreviousCoding StandardsNextDiving into PrestaShop Core development

Last updated 4 years ago

Was this helpful?

Table of contents

/*<![CDATA[*/ div.rbtoc1597308499587 {padding: 0px;} div.rbtoc1597308499587 ul {list-style: disc;margin-left: 0px;} div.rbtoc1597308499587 li {margin-left: 0px;padding-left: 0px;} /*]]>*/

Setting up your local development environment

Now that you intend to develop for PrestaShop, you are better off keeping all your development work on your machine. The main advantage is that it makes it possible for you to entirely bypass the process of uploading your file on your online server in order to test it. Another advantage is that a local test environment enables you to test code without the risk of breaking your production store. Have a local environment is the essential first step in the path of web development.

Installing PrestaShop 1.5 locally

Prerequisites

PrestaShop needs the following server configuration in order to run:

  • System: Unix, Linux or Windows.

  • Web serve: Apache Web Server 1.3 or any later version.

  • PHP: 5.2 or later.

  • MySQL: 5.0 or later.

  • At least 32 Mb of RAM. 64 Mb is more comfy, the more the better...

PrestaShop can work with PHP 5.1.3 or later, but versions inferior to 5.2 have bugs that might prevent some functionalities to work as expected (such as invalid date time zone).

PrestaShop can also work with Microsoft's IIS Web server 6.0 or later, and nginx 1.0 or later.

Installing a local environment

Installing any web-application locally requires that you first install the adequate environment, namely the Apache web server, the PHP language interpreter, the MySQL database server, and ideally the phpMyAdmin tool. This is called an AMP package: Apache+MySQL+PHP and the operating system, giving WAMP (Windows+Apache+MySQL+PHP), MAMP (Mac OS X+...) and LAMP (Linux+...). Since all of the items packaged are open-source, these installers are most of the time free.

Here is a selection of free AMP installer:

Configuring PHP

PrestaShop needs a few additions to PHP and MySQL in order to fully work. Make sure that your PHP configuration has the following settings and tools:

  • GD library.

  • Dom extension.

  • allow_url_fopen enabled.

Here is a section of the php.ini file (the configuration file for PHP):

extension = php_mysql.dll
extension = php_gd2.dll
allow_url_fopen = On
    
# also recommended
register_globals = Off
magic_quotes_gpc = Off
allow_url_include = Off

The Dom extension enables to parse XML documents. PrestaShop uses it for various functionalities, like the Store Locator. It is also used by some modules, as well as the pear_xml_parse library.

The allow_url_fopen directive enables modules to access remote files, which is an essential part of the payment process, among others things. It is therefore imperative to have it set to ON.

Downloading and extracting the PrestaShop files

Extract the PrestaShop files, and put them in the root folder of the AMP installer you chose:

  • XAMPP: C:\xampp\htdocs or /Applications/xampp/htdocs

  • WampServer: C:\wamp\www

  • EasyPHP: C:\easyphp\www

  • MAMP: /Applications/MAMP/htdocs/

Creating a database for your local shop

Open the phpMyAdmin tool using your browser. Its location depends on the AMP pack you chose:

In the "Databases" tab, indicate the database name you want and validate by clicking on the "Create a database" button.

Installing PrestaShop

Configuring PrestaShop

By default, PrestaShop is configured to provide a secure and stable environment to both the shop administrator and the customers.

As a developer, there are several changes that you could and should bring to the default installation in order to help you code better, spot bugs faster, and generally make a great PrestaShop product.

Disabling the cache and forcing Smarty compilation

When your development has an impact on the front-office, whether you are building a theme or simply a module which displays information to the customer, you should force the template file compilation and disable the cache, so as to always see the result of your changes directly.

Go to the "Performances" page under the "Advanced parameters" menu to change the following Smarty settings:

  • Template cache: switch it to "Force compilation".

  • Cache: disable it.

Forcing the compilation of Smarty will always slow down the loading time of the page. Make sure that your production store is set to only recompile templates if there are updated files, and that its cache is enabled.

Displaying error messages

PrestaShop's default settings prevent the customer to see any server error message or any debugging code.

You, on the other hand, need this information in order to correct any potential mistake in your code. To that end, open the /config/defines.inc.php file, and edit it to set _PS_MODE_DEV_ to true:

/* Debug only */
define('_PS_MODE_DEV_', true);

Using the debug methods

echo '<xmp style="text-align: left;">';
print_r($variable);
echo '</xmp><br />';
return $variable;

This type of function is typical of many PHP development sessions, and PrestaShop enables you to not have to reinvent the wheel with this method.

p() is the main method, and d() works the same way, except that it calls the die() method instead of returning the variable:The d() method

echo '<xmp style="text-align: left;">';
print_r($variable);
echo '</xmp><br />';
die('END');

These two methods enable you to check for the state of a given variable at a specific place within your code.

On top of that, PrestaShop defines the ppp() and ddd() methods, which are respectively the aliases of p() and d(). They work exactly the same, but are often easier to search and find in a huge block of code.

These debug methods are not activated by default. To activate them, you must enable the Debug mode, by setting _PS_MODE_DEV_ to true (see above).

Enabling the multistore mode

PrestaShop 1.5 is able to host more than one store within a single installation of the software. Many shop administrators choose to enable this feature, and it can have a significant impact on the way PrestaShop works. You should therefore make sure that anything you code for PrestaShop works in both single and multistore mode.

Enabling the multistore mode is easy: go to the general preferences page, and put the "Enable Multistore" option to "Yes".

You can switch back and forth between single store and multistore mode – in single store mode, only the main store is used.

About the configuration files

There are three main configuration files, all located in the /config folder:

  • config.inc.php

  • defines.inc.php

  • smarty.inc.php

config.inc.php

It is the main configuration file for PrestaShop. You should not have to touch anything in there.

defines.inc.php

This file contains PrestaShop constant values.

It also contains the location of all the files and folders. If you need to change their location, do not forget to keep the original path nearby, for instance in a PHP comment, in case you need to revert back to it later on.

When in development/test mode, you must make sure that all the error messages are displayed:

  • Set define('_PS_MODE_DEV_', false); to true.

On the contrary, when in production mode, you must hide error messages as much as possible!

  • Make sure that define('_PS_MODE_DEV_', false); is set to false.

smarty.inc.php

This file contains all the Smarty-related settings.

The Smarty cache system should always be disabled, as it is not compatible with PrestaShop: keep $smarty->caching = false; as it is.

$smarty->compile_check should be left to false in development mode.

$smarty->debugging gives access to Smarty debug information when displaying a page. That setting is more easily modified in the "Performance" page of the advanced parameters menu : the "Debug console" option enables you to choose between never displaying Smarty's debug information, always displaying it, or only displaying it when you add ?SMARTY_DEBUG to the URL of the page you want to test, which can be very useful.

When in production mode, $smarty->force_compile must be set to false, as it will give a 30% boost to your page load time.

On the other hand, when editing a .tpl file, you must delete the /tools/smarty/compile folder (except the index.php file) in order to see your changes applied.

Note that this setting can be made directly from the back-office, in the "Performance" page under the "Advanced parameters" menu.

XAMPP: (Windows, Mac OS X, Linux, Solaris)

WampServer: (Windows)

EasyPHP: (Windows)

MAMP: (Mac OS X)

The GD library () enables PrestaShop to rework images that you upload, especially resizing them.

You can download the latest version of PrestaShop at .

You can download the (unstable) development version on Github:

(XAMPP, WampServer, MAMP),

(EasyPHP)

Open the PrestaShop installer, which should be located at , and follow its instructions.

You can read the Getting Started guide for more details: .

PrestaShop has custom debug methods available for developers: p($variable) and d($variable). They are used to display the content of a variable. It is really a wrapper around the well-known print_r() method ():The p() method

You can read more about the multistore mode in the PrestaShop 1.5 User Guide: .

http://www.apachefriends.org/en/xampp.html
http://www.wampserver.com/en/
http://www.easyphp.org/
http://www.mamp.info/
http://www.boutell.com/gd/
http://www.prestashop.com/en/downloads
https://github.com/PrestaShop/PrestaShop/archive/development.zip
http://127.0.0.1/phpmyadmin
http://127.0.0.1/mysql
http://127.0.0.1/prestashop/install
http://doc.prestashop.com/display/PS15/Getting+Started
http://php.net/manual/en/function.print-r.php
http://doc.prestashop.com/display/PS15/Managing+Multiple+Shops
Setting up your local development environment
Installing PrestaShop 1.5 locally
Prerequisites
Installing a local environment
Configuring PHP
Downloading and extracting the PrestaShop files
Creating a database for your local shop
Installing PrestaShop
Configuring PrestaShop
Disabling the cache and forcing Smarty compilation
Displaying error messages
Using the debug methods
Enabling the multistore mode
About the configuration files
config.inc.php
defines.inc.php
smarty.inc.php