Skip to content

Preparing for LiteCommerce module development

seyfin edited this page Nov 17, 2012 · 10 revisions

Module Developer's Tutorial - Preparing for LiteCommerce module development

Installing LiteCommerce

Although you can develop modules directly over a regular LiteCommerce installation, we recommend you to get the most recent LiteCommerce version from our GitHub repositories, because it comes with multiple tools that may help you develop and test your module. Also, it makes sense to develop a module for a LC+Drupal version and then test it in the stand-alone LC version.

  1. Install Git on the computer where you will be working on the module. If you aren’t familiar with Git, there is a great book available free of charge.

    If this is a local computer, install web server applications as per LiteCommerce requirements. You may install one of these pre-built web-server packages like WAMP, XAMPP, MAMP and so on.

  2. Create a single MySQL database for Drupal and LiteCommerce data

  3. Download Drupal and LiteCommerce files from our GitHub repositories to your web directory by executing the following commands in a terminal window:

    • cd <path_to_your_web_directory>
    • git clone git://github.com/litecommerce/core.git xlite
    • git clone git://github.com/litecommerce/drupal.git xlite_cms
    • cd xlite_cms
    • git submodule update --init (this command will add "lc_connector" module and "lc3_clean" theme which are located in separate repositories)
    • cd ..

    If you want to keep a history of your changes, you can "fork" our GitHub repositories and commit your files to your GitHub account.

    Moreover, forking our GitHub repositories enable you to submit us your fixes and improvements to the LiteCommerce code (by sending us a "pull request").

  4. Switch to the Git branches with the most recent (untested) version:

    • cd xlite
    • git checkout -b master-dev origin/master-dev (to get a Release Candidate version use git checkout VERSION instead, where VERSION is the full version number without the ending "RC"; for example, git checkout 1.0.13)
    • cd ../xlite_cms
    • git checkout -b 7.x-master-dev origin/7.x-master-dev
    • cd ..
  5. Create configuration files:

    • cp xlite/src/etc/config.default.php xlite/src/etc/config.php
    • cp xlite_cms/sites/default/default.settings.php xlite_cms/sites/default/settings.php

    And specify your database settings in the "config.php" and "settings.php" files. In the "settings.php" file, set "prefix" in the $databases variable to "drupal_"; in the "config.php" file, set "table_prefix" to "xlite_". In the "config.php" file, also specify your domain (in the "host_details" section) and set "web_dir" to "/xlite/src/".

  6. Make sure the "xlite/src/var" and "xlite_cms/sites" directories have permissions that allow the web server to write files there. It really depends on your server environment, so please ask your server administrator how you can configure the permissions without opening a security breach.

  7. Initialize the LiteCommerce database:

    • cd xlite/src
    • php -f restoredb demo
    • cd ../..
  8. Rebuild the LC3 classes cache by opening the http://<domain>/<path>/xlite/src/admin.php script in a browser

  9. Prepare for Drupal installation:

    • cp xlite_cms/.dev/dev_install.php xlite_cms/dev_install.php

    And run the Drupal installation script in a browser: http://<domain>/<path>/xlite_cms/dev_install.php

Locating LiteCommerce files

Depending on how you installed LiteCommerce, you can find its files at the following locations:

  1. LC+Drupal version from the pre-built Ecommerce CMS installation package:

    • Drupal files are in the directory where the package is installed into
    • LC files can be found under the modules/lc_connector/litecommerce/ subdirectory
  2. LC+Drupal version from our GitHub repositories:

    • Drupal files are in the directory where drupal.git repository is extracted into (more likely it is "xlite_cms")
    • LC files are in the directory where core.git repository is extracted into (more likely it is "xlite/src")
  3. A stand-alone version from an installation package:

    • LC files are in the directory where the package is installed into
  4. A stand-alone version from our GitHub repostiory:

    • LC files are in the directory where core.git repository is extracted into (more likely it is "xlite/src")

Further in the instructions, the directory with LiteCommerce files is referred to as just "<xlite>/", and the one with Drupal files - as "<xlite_cms>/".

Configuring developer-specific settings

First of all, copy the <xlite>/etc/config.default.php file to <xlite>/etc/config.php (if you haven’t copied it yet) and edit the config.php file. The settings that you are to look into are:

  1. [log_details] section

    • name - path to log file
    • suppress_errors - disables showing errors in browser
    • suppress_log_errors - disables recording errors to log file
  2. [profiler_details] section

    • enabled - enables profiler and displays profiler results at the bottom of the page
    • process_widgets - counts time necessary to render every page template
    • xdebug_log_trace - enables Xdebug function traces
    • show_messages_on_top - displays debug messages at the top of the page instead of using the profiler results section at the bottom (this option requires developer_mode option to be enabled). You can display a debug message by adding the following function call to your code: \XLite\Core\Profile::getInstance()->addMessage(<text>);
  3. [debug] section

    • mark_templates - displays debug information on LiteCommerce widgets and templates shown on the page
  4. [decorator] section

    • time_limit - sets time limit for the script that rebuilds LiteCommerce cache (in seconds)
  5. [performance] section

    • substitutional_skins_cache - when the option is enabled, LiteCommerce caches information on which templates files should be taken from which skin directories; this may boost the performance when you have a theme that extends another one.
    • developer_mode - enables debug messages and the function of creating a module package from an installed module on the back-end page listing modules. You can display a debug message by adding the following function call to your code: \XLite\Core\Profile::getInstance()->addMessage(<text>);

Also, in the LiteCommerce back-end, on the "Performance" page (top menu > "Settings" > "General settings" > "Performance" tab), there is a "Check templates status in runtime" option. When the option is disabled, LiteCommerce never checks whether a template file exists in the file system before opening it. That may increase the performance of a "live" shop, but in the development environment it is recommended to keep this option enabled. Also, in the developer mode, the option is always enabled.

When done editing the settings file, open the LiteCommerce back-end and start rebuilding the LiteCommerce classes cache by selecting the command on the top menu (under the "Maintenance" item).

Clone this wiki locally