Dev docs
- Module sort order
- Making release
- Keep the modules up to date
- Updating TM packages repository
- Magento Extension Quality Program Coding Standard
- PHP Mess Detector
- PHP Coding Standards Fixer
- PHP Copy/Paste Detector
- PHPLint
- PHPStan
- ESLint
- JSCS
Before start
Directory structure
You can use the following directory structure:
D:
└── www
├── dev
| ├── satis — Library that is used to build packages repository
| └── composer — Manage module dependencies
├── logs — Apache, php, mysql logs
└── public — Web server public folder
├── magento
| ├── htdocs — Magento repository
| ├── vendor — Magento modules
| └── composer.json — List of modules to install with composer
├── packages — Packages repository built with satis
└── phpmyadmin
Required software
Mysql
- Mysql server
- HeidiSql client
- PhpMyAdmin - Unpack it to
www/public/phpmyadmin
directory
Php
- Download and unpack binaries to
C:\php
folder. - Rename
php.ini-development
tophp.ini
-
Apply the following changes to
php.ini
:max_execution_time = 600 memory_limit = 512M error_reporting = E_ALL error_log = "D:\www\logs\php_error.log" post_max_size = 256M doc_root = d:\www\public extension_dir = "ext" upload_max_filesize = 256M extension=php_curl.dll extension=php_gd2.dll extension=php_intl.dll extension=php_mbstring.dll extension=php_mysqli.dll extension=php_openssl.dll extension=php_pdo_mysql.dll date.timezone = 'America/Los_Angeles'
- Add
C:\php
folder to system PATH
Apache
- Download
and unpack binaries to
/c/Apache24
-
Find the following settings in
conf/httpd.conf
and change them as shown below:ServerRoot "c:/Apache24" Listen 80 # LoadModule cgi_module modules/mod_cgi.so LoadModule rewrite_module modules/mod_rewrite.so ServerName your_local_ip_address:80 DocumentRoot "D:/www/public" AllowOverride All Require all granted <Directory "D:/www/public"> DirectoryIndex index.php index.html ErrorLog "D:/www/logs/apache_error.log"
-
Add the following settings to the bottom of the file:
LoadModule php5_module "c:/php/php5apache2_4.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php"
Git
-
- Add the git to the system PATH during installation
- Select checkout as-is and commit as-is option
-
Setup git
git config --global user.name "FirstName LastName" git config --global user.email "your_email@example.com" git config --global core.autocrlf false git config --global push.default simple
-
Setup github account and generate ssh key
Composer
- Install composer
- Windows installation
- Manual installation. Add composer to the system PATH variable.
- Add composer to your github authorized applications and copy generated token.
-
Run the following command in terminal:
composer -g config github-oauth.github.com YOUR_KEY_HERE
Satis
-
Download satis
cd www/dev composer create-project composer/satis --stability=dev --keep-vcs
-
Add
www/dev/satis/bin
folder to system PATH variable.
Node.js and gulp.js
- Install Node.js
-
Install Gulp.js
npm install -g gulp
Magento installation
Magento
-
Clone Speedupmate Magento repository:
cd www/public/magento git clone git@github.com:speedupmate/Magento-CE-Mirror.git htdocs cd htdocs git checkout magento-ce-1.9.4.4 echo '*' > .gitignore cp errors/local.xml.sample errors/local.xml
- Install magento sample data
- Open
192.168.1.xxx/magento/htdocs
address in browser and install Magento - Navigate to backend
System > Configuration > Developer > Template Settings
and setAllow Symlinks
option to “Yes” - Enable logs at
System > Configuration > Developer > Log Settings
configuration - Disable cache at
System > Cache Management
TM modules
-
Create
composer.json
file and save it underwww/public/magento
folder:{ "minimum-stability": "dev", "require": { "magento-hackathon/magento-composer-installer": "3.0.*", "tm/argento": "*", "tm/attributepages": "*", "tm/bot-protection": "*", "tm/cache": "*", "tm/countdowntimer": "*", "tm/dailydeals": "*", "tm/easyflags": "*", "tm/easylightbox": "*", "tm/easynavigation": "*", "tm/firecheckout": "*", "tm/helpdesk": "*", "tm/pagespeed": "*", "tm/prozoom": "*", "tm/quickshopping": "*", "tm/productvideos": "*", "tm/recaptcha": "*", "tm/review-reminder": "*", "tm/smartsuggest": "*", "tm/socialsuite": "*", "tm/testimonials": "*" }, "repositories": [ { "type": "composer", "url": "http://tmhub.github.io/packages" }, { "type": "composer", "url": "http://packages.firegento.com" } ], "extra": { "magento-root-dir": "htdocs/", "magento-deploystrategy": "symlink", "magento-force": true }, "config": { "discard-changes": true, "secure-http": false } }
-
Run the following commands from terminal with admin privileges:
cd www/public/magento composer install
All modules will be automatically downloaded to the
www/public/magento/vendor/tm
folder and symlinked intowww/public/magento/htdocs
. So you can edit files in bothvendor/tm
andhtdocs
folders.
Module development
Module sort order
Use two or three letters of module code to determine the module sort order.
It’s recommended to use the two letters, bacause the third letter calculation is not accurate.
0
AjaxLayeredNav - alnAjaxPro - apr
FireCheckout - fir
For Example:
Module Name | Code for sortorder script | Sort Order |
---|---|---|
AjaxLayeredNavigation | aln | 146 |
AjaxPro | apr | 161 |
EasyTabs | eta | 574 |
Full Page Cache | fpc | 659 |
Firecheckout | fir | 635 |
Making release
- Use release builder script to generate archive.
- Upload the generated archive to github release.
Keep the modules up to date
- Commit all of your changes to github
- Update packages repository
-
Run terminal window with admin privileges.
Do not run this command if you didn’t complete first or second step!
cd www/public/magento composer update
There is a chance that something will went wrong during
composer update
command. In case if all modules are downloaded by composer but not deployed to the magento folder, use the following command:composer run-script post-install-cmd -vvv -- --redeploy
Updating TM packages repository
TM packages repository is used by composer dependency manager to download
module dependencies during composer install
and composer update
commands.
cd www/public
# clone repository
git clone git@github.com:tmhub/packages.git && cd packages
# update the repository and push changes:
./run.sh
Magento Extension Quality Program Coding Standard
Magento EQP Coding Standard is a set of rules and sniffs for PHP_CodeSniffer tool. It allows automatically check your code against some of the common Magento and PHP coding issues, like:
- raw SQL queries;
- SQL queries inside a loop;
- direct class instantiation;
- unnecessary collection loading;
- excessive code complexity;
- use of dangerous functions;
- use of PHP superglobals;
- code style issues
- and many others.
Magento Extension Quality Program Coding Standard consists of two rulesets - MEQP1 for Magento and MEQP2 for Magento 2. Each of them contains the rules depending on the requirements of each version.
#installation
composer create-project --repository=https://repo.magento.com magento/marketplace-eqp magento-coding-standard
cd magento-coding-standard
#set installed path option
vendor/bin/phpcs --config-set installed_paths ../../..
# Check Magento extension run
vendor/bin/phpcs /path/to/your/extension --standard=MEQP1
# Check Magento 2 extension run
vendor/bin/phpcs /path/to/your/extension --standard=MEQP2
# Marketplace Technical Review
# you could run phpcs command with --severity=10 option.
vendor/bin/phpcs /path/to/your/extension --standard=MEQP2 --severity=10
# Auto code clean
vendor/bin/phpcbf /path/to/your/extension --standard=MEQP2 --no-patch
PHP Mess Detector
What PHPMD does is: It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like:
- Possible bugs
- Suboptimal code
- Overcomplicated expressions
- Unused parameters, methods, properties
wget -c http://static.phpmd.org/php/latest/phpmd.phar
sudo chmod a+x phpmd.phar
sudo mv phpmd.phar /usr/local/bin/phpmd
phpmd ~/tm/ajax-search text /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
phpmd ~/swissup/ajaxsearch text /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
wget -c https://raw.githubusercontent.com/kubaceg/phpmd-magento/master/ruleset.xml -O ruleset1.xml
phpmd ~/swissup/ajax-search text ruleset1.xml
/**
* @SuppressWarnings(PHPMD)
*/
Typical warnings
/**
*
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
PHP Coding Standards Fixer
The PHP Coding Standards Fixer tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents and many more.
wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
sudo chmod a+x php-cs-fixer
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
php-cs-fixer fix ~/tm/ajaxpro --dry-run
php-cs-fixer fix ~/tm/ajaxpro --dry-run --rules=@PSR2
php-cs-fixer fix ~/tm/ajaxpro
PHP Copy/Paste Detector (PHPCPD)
phpcpd is a Copy/Paste Detector (CPD) for PHP code.
$ wget https://phar.phpunit.de/phpcpd.phar
$ chmod +x phpcpd.phar
$ mv phpcpd.phar /usr/local/bin/phpcpd
# Usage Example
$ phpcpd ~/tm/ajaxpro
PHPLint
phplint is a node wrapper around the native php linter that allows for parallel linting and integration with build systems like Grunt, Gulp and more.
http://www.icosaedro.it/phplint/
$ npm i -g phplint
# Usage Example
$ phplint ~/tm/ajaxpro/**/*.php
$ phplint ~/tm/ajaxpro/**/*.phtml
Native php lint
$find ~/tm/ajaxpro -type f -name "*.php" -exec php -d display_errors=1 -l {} \;
$find ~/tm/ajaxpro -type f -name "*.phtml" -exec php -d display_errors=1 -l {} \;
PHPStan
PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.
https://github.com/phpstan/phpstan
$ wget -O phpstan.phar https://github.com/phpstan/phpstan/releases/download/0.8.4/phpstan.phar
$ chmod +x phpstan.phar
$ mv phpstan.phar /usr/local/bin/phpstan
# Usage Example
$ phpstan analyze -l 4 ~/tm/ajaxpro
ESLint
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs.
- ESLint Getting Started
- ESLint Command options
- Magento JavaScript coding standard
- Magento ESLint Rules
# Install
$ npm install -g eslint
# Usage Example
$ eslint --ext .jsx,.js --config /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento ~/swissup/ajaxpro/view/**
# Auto fix
eslint --fix --ext .jsx,.js --config /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento ~/swissup/ajaxpro/view/**
If you want to disable eslint and jscs validation for some third party js file
diff --git a/view/frontend/web/js/typeaheadbundle.js b/view/frontend/web/js/typeaheadbundle.js
index bb0c8ae..81d8307 100644
--- a/view/frontend/web/js/typeaheadbundle.js
+++ b/view/frontend/web/js/typeaheadbundle.js
@@ -3,6 +3,8 @@
* https://github.com/twitter/typeahead.js
* Copyright 2013-2015 Twitter, Inc. and other contributors; Licensed MIT
*/
+/* eslint-disable */
+/* jscs:disable */
(function(root, factory) {
if (typeof define === "function" && define.amd) {
@@ -2448,4 +2450,6 @@
return $el.length ? $el : null;
}
})();
-});
\ No newline at end of file
+});
+/* eslint-enable */
+/* jscs:enable */
JSCS
JSCS is a code style linter and formatter for your style guide
# Install
$ npm install jscs -g
# Usage Example
$ jscs ~/swissup/ajaxpro/view/** --extract .phtml --config /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc
# Auto fix
jscs ~/swissup/ajaxpro/view/** --fix --extract .phtml --config /var/www/local.magentocommerce2.com/htdocs/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc
Miscellaneous
Terminal
ConEmu is nice one.
Using GitBash in ConEmu:
Navigate to Settings > Startup > Tasks > New
and create new tasks:
-
GitBash
Parameters: /dir "D:\www" Commands: "C:\Program Files (x86)\Git\bin\sh.exe" --login -i
-
GitBash with admin privileges:
Parameters: /dir "D:\www" Commands: "C:\Program Files (x86)\Git\bin\sh.exe" --login -i -new_console:a
Sublime text editor
- Download and install text editor
- Install Package Control
- Download sublime setting files
and place them into
%APPDATA%/Sublime Text 3/Packages/User
Open VPN in Ubuntu
-
Run command in terminal to install required apps:
sudo apt-get install network-manager-openvpn-gnome openvpn
- Go to VPN connections settins and configure VPN. In
Connection type
drop-down select ‘Open VPN’. Set Gateway54.195.241.132:1194
- In Advanced settings check
Use LZO data compression
option (tab ‘General’).