Developing & Contributing

Minimum PHP Version

Nosto extension supports Magento >= 2.2, which requires at least PHP 7.0.13 to run.

Required PHP 7 extensions

Magento 2 requires the following extensions to run:

curl
dom
gd
hash
iconv
mcrypt
pcre
pdo
pdo_mysql
simplexml
curl
gd
intl
mbstring
mcrypt
hash
openssl
soap
xml
xsl
zip

To run the dev scripts from Nosto you are required to install the following PHP extensions

ast
pcntl

In order to install the ast extension using PECL, run pecl install ast and the ast.so extension will be added to load in you php.ini configuration file. The pcntl comes by default if you install PHP via Homebrew. If you compiled PHP yourself, you need to recompile the sources with the --enable-pcntl flag and load the extension in the php.ini file.

Checking Extensions

You can easily check that all required extensions are installed piping this script to you local PHP binary

curl https://gist.githubusercontent.com/supercid/fbf020ed8bdb15f5f72fd45a820703c3/raw/5defa0554f45fe14b085dc9e461e6c684e716ed4/nosto-check-m2-extensions.php | php

Local Code Quality Check

In order to maintain code quality we use PHPCS and PHAN to analyse the extension code. If your code does not follow the custom rules described in the ruleset.xml file (Mostly PSR-2), the CI will reject your code and you will not be able to merge until the violations are fixed. We recommend to run the checks, both PHAN and PHPCS, before pushing and opening a pull-request.

Running Phan Locally

Install the dev dependencies by running composer install on Nosto root directory: %Magento2Root%/vendor/nosto/module-nostotagging

After which you will be able to run Phan: ./vendor/bin/phan --config-file=phan.php --output-mode=checkstyle

Running PHP Code Sniffer Locally

You can check the style by running the following command on your Nosto installation root: ./vendor/bin/phpcs --standard=ruleset.xml --report=checkstyle

Symlinking Extension Directory

If you need to test the extension against multiple installations and versions of Magento, the best way to do it is to clone the extension repository in a folder outside Magento installation and symlink this copy to $Magento%/vendor/nosto/module-nostotagging directory. You can do so by running the following command:

ln -s path/to/extensions/repository path/to/magento/vendor/nosto/module-nostotagging

Generate data

You can generate data for performance testing purposes. You can choose the amount of data to be generated by choosing profiles and select which file you need. The profiles are located under the following directory

<magento-2-installation>/setup/performance-toolkit/profiles/<ce or ee>

If you want to customize the amount of data generated, just modify the value inside the tags. Fo example the amount of simple-products is found inside the tags:

<simple_products>{integer}</simple_products>

The fields needed for product data related are:

Simple product: <simple_products> ... </simple_products>

Configurable product: <configurable_products> ... </configurable_products>

Images <product-images> ... </product-images>

Run the command.

bin/magento setup:perf:generate-fixtures <path-to-profile>

For example::

bin/magento setup:perf:generate-fixtures <magento-2-installation>/setup/performancetoolkit/profiles/ce/medium.xml

For more detailed setup you can follow the Magento 2 documentation.