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:
To run the dev scripts from Nosto you are required to install the following PHP extensions
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
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:
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. For 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.
For example::
For more detailed setup you can follow the Magento 2 documentation.
Connecting your local Magento instance to Nosto
Install Ngrok
Visit the Ngrok website and sign up for an account if you haven't already.
Download the Ngrok binary for your operating system. Extract the downloaded file to a directory of your choice. Open a terminal or command prompt and navigate to the directory where you extracted the Ngrok binary.
Valid Domains
We need a valid TLD domain, meaning that .test
domains are not accepted by Nosto and your updates will be discarded by our crawler.
Start Ngrok Tunnel
In the terminal, run the following command to start an HTTP tunnel:
or if you're using a local SSL certificate:
Replace 80/443 with the port number your Magento local instance is running on if it's different. Ngrok will generate a public URL that forwards requests to your local Magento server. You'll see the forwarding URL displayed in the terminal window.
Configure Magento
Access Your Magento Site
With Ngrok running and configured, you can now access your local Magento site via the Ngrok forwarding URL. Open a web browser and enter the Ngrok HTTPS URL generated in the terminal (e.g., https://randomstring.ngrok.io/). Your local Magento website should now be accessible via the Ngrok tunnel.
Additional Tips:
Ngrok URLs are temporary and change every time you restart Ngrok, therefore we recommend using a paid Ngrok account to ensure that the URL stays the same. You can, however, use a script to change your Magento domain every time you restart Ngrok or your temporary domain changes.
Ngrok provides a secure tunnel with HTTPS support, allowing you to test features like order tracking, product updates via crawler and product image crawling as well on your local Magento site.
Remember to stop Ngrok when you're finished testing to prevent unauthorized access to your local server.
Last updated