SlideShare a Scribd company logo
PHP
Development Tools
Why I like PHPStorm
● You can develop applications in PHP versions 5.3/5.4/5.5/5.6/7.0/7.1, SQL & PL/SQL,
JavaScript, XML, HTML, CSS.
● You can add functionality to our IDE by installing plugins (Bash, Symfony, Laravel,
Magento 2, NodeJS, LiveEdit, Spy-JS, Meteor).
● Support for Vagrant and Docker, Docker Compose, SSH console & remote tools.
● Databases and SQL Editor in PhpStorm (MySQL, PostgreSQL, Oracle, SQLite, etc)
● Coding style Support PSR1/PSR2, PHPDoc support.
● Version control systems integration Git, Subversion, Mercurial, Perforce, CVS, TFS
● Duplicated Code Detector. PHP Code Sniffer (phpcs) that checks for code smells on
the fly. Local History. Debugging with Xdebug and ZendDebugger.
Advantages of Using Docker
Portability across machines – an application and all its dependencies
can be bundled into a single container that can be transferred to
another machine that runs Docker, and executed there without
compatibility issues.
Version control and component reuse – you can track successive
versions of a container, inspect differences, or roll-back to previous
versions.
Sharing – you can use a remote repository to share your container
with others.
Client, Docker Host, Registry
Docker Usage
~$ docker pull node:latest
~$ docker run -it --name="angular_test" node:latest /bin/bash
~$ npm install -g @angular/cli
~$ docker build -t angular-img .
~$ docker commit -m="This a test angular image" angular_test my.gitlabrepo/test_repo
~$ docker login && docker push my/test_repo
Docker File Example
FROM php:5.6-fpm
RUN apt-get update && apt-get install -y libfreetype6-dev libicu-dev libjpeg62-turbo-dev 
libmcrypt-dev libpng-dev libxslt1-dev
RUN docker-php-ext-install gd mcrypt mbstring sockets zip xsl soap
RUN pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug
ADD ./etc/init.d/php/run.sh /run.sh
RUN curl -Lsf 'https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz' 
| tar -C '/usr/local' -xvzf -
ENV PATH /usr/local/go/bin:$PATH
RUN go get github.com/mailhog/mhsendmail
RUN cp /root/go/bin/mhsendmail /usr/bin/mhsendmail
Solr Docker File
FROM java:6
RUN mkdir -p /opt/solr
RUN cd /tmp && curl https://archive.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz | tar xvz &&
mv -v apache-solr-3.6.1/* /opt/solr
EXPOSE 8983
VOLUME ["/opt/solr/example/solr/data", "/opt/solr/example/solr/conf"]
WORKDIR /opt/solr/example
CMD java -jar start.jar
Every Day Docker Commands
~$ docker ps -a
~$ docker stop|start|restart container_name
~$ docker run --name ubuntu -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
~$ docker exec -it ubuntu bash
~$ docker logs ubuntu
~$ docker history ubuntu
~$ docker stats
Docker Search
~$ docker search node
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
node Node.js is a JavaScript-based platform for... 5829 [OK]
mhart/alpine-node Minimal Node.js built on Alpine Linux 366
mongo-express Web-based MongoDB admin interface, written... 269 [OK]
nodered/node-red-docker Node-RED Docker images. 168 [OK]
iojs io.js is an npm compatible platform origin... 126 [OK]
prom/node-exporter 83 [OK]
readytalk/nodejs Node.js based off the official Debian W
One Line Scripts
~$ curl -s https://registry.hub.docker.com//v1/repositories/php/tags | php -r
'print_r(json_decode(file_get_contents("php://stdin")));' | grep fpm | head -20
~$ sudo nano /usr/local/bin/docker-tags
~$ sudo chmod +x /usr/local/bin/docker-tags
#!/usr/bin/env bash
curl -s https://registry.hub.docker.com//v1/repositories/$1/tags | php -r
'print_r(json_decode(file_get_contents("php://stdin")));' | grep name | grep $2 | head -$3
Docker Tags
~$ docker-tags php fpm 10
[name] => 5-fpm-alpine
[name] => 5-fpm-alpine3.4
[name] => 5-fpm-alpine3.7
[name] => 5-fpm-jessie
[name] => 5-fpm-stretch
[name] => 5.4-fpm
[name] => 5.4.35-fpm
[name] => 5.4.36-fpm
[name] => 5.4.37-fpm
[name] => 5.4.38-fpm
One Line Scripts PHP
~$ sudo nano /usr/local/bin/docker-tag-php
#!/usr/bin/php -q
<?php
$repoCh = curl_init('https://registry.hub.docker.com//v1/repositories/' . $argv[1] . '/tags');
curl_setopt($repoCh, CURLOPT_RETURNTRANSFER, 1);
foreach (json_decode(curl_exec($repoCh)) as $tag) {
echo $tag->name . PHP_EOL;
}
curl_close($repoCh);
~$ sudo chmod +x /usr/local/bin/docker-tag-php
Docker Tags PHP
~$ docker-tags-php node | grep jessie | tail -n 10
8.11-jessie
8.11.2-jessie
8.11.3-jessie
9-jessie
9.11-jessie
9.11.1-jessie
9.11.2-jessie
boron-jessie
carbon-jessie
jessie
Kinematic
Portainer
docker-compose up
Runs services via docker-compose util:
● db - MySql database service
● app - PHP5.6-FPM service
● web - Nginx web server
● redis - Redis session and cache storage
● mongo - Mongo NoSql storage used for price service
● rabbit - RabbitMQ queue server
● solr -Apache Solr service for fulltext search
● bps - Backend price service on Python Tornado
● fps - Frontend price service on PHP
● worker - PHP worker for background jobs
● cron - Run application schedule tasks
● mailservice - Caught all mail from application
Docker Compose File Example
version: '3'
services:
influx:
image: influxdb
volumes:
- ./docker/var/lib/influx:/var/lib/influxdb
- ./docker/etc/init.d/influxdb:/docker-entrypoint-initdb.d
grafana:
image: grafana/grafana
ports:
- 127.0.0.1:3000:3000
volumes:
- ./docker/var/lib/grafana:/var/lib/grafana
depends_on:
- influx
cadvisor:
image: google/cadvisor
ports:
- 127.0.0.1:8080:8080
command: -logtostderr -docker_only -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influx:8086
Grafana
Coding style guide PSR-1
● Files MUST use only <?php and <?= tags.
● Files MUST use only UTF-8 without BOM for PHP code.
● Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause
side-effects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both.
● Namespaces and classes MUST follow an “autoloading” PSR: [PSR-0, PSR-4].
● Class names MUST be declared in StudlyCaps.
● Class constants MUST be declared in all uppercase with underscore separators.
● Method names MUST be declared in camelCase.
Coding style guide PSR-2
● Code MUST use 4 spaces for indenting, not tabs.
● There MUST NOT be a hard limit on line length; the soft limit MUST be 120
characters; lines SHOULD be 80 characters or less.
● There MUST be one blank line after the namespace declaration, and there
MUST be one blank line after the block of use declarations.
● Opening braces for classes MUST go on the next line, and closing braces MUST
go on the next line after the body.
● Opening braces for methods MUST go on the next line, and closing braces MUST
go on the next line after the body.
● Visibility MUST be declared on all properties and methods; abstract and
final MUST be declared before the visibility; static MUST be declared
after the visibility.
● Control structure keywords MUST have one space after them; method and
function calls MUST NOT.
● Opening braces for control structures MUST go on the same line, and closing
braces MUST go on the next line after the body.
● Opening parentheses for control structures MUST NOT have a space after them,
and closing parentheses for control structures MUST NOT have a space before.
File | Settings | Editor | Code Style | PHP
PHP Code Sniffer
● WordPress-Coding-SWordPress-Coding-Standardstandards/
● object-calisthenics/phpcs-calisthenics-rules
● yiisoft/yii2-coding-standards
● Symplify/EasyCodingStandard
● joomla/coding-standards
~$ sudo nano composer.json
{
"require": {
"magento-ecg/coding-standard": ">=3.0",
"squizlabs/php_codesniffer": "3.*"
}
}
PHP CS Setup
Setup PHPCS in PHPStorm:
In PHPStorm open File > Settings > Languages & Frameworks> PHP > Code Sniffer
Click to configuration, in opened popup click to the (+) and provide path to phpcs launcher.
PHP MD Setup
Setup PHPMD in PHPStorm:
In PHPStorm open File > Settings > Languages & Frameworks> PHP > Mess Detector
Click to configuration, in opened popup click to the (+) and provide path to phpmd launcher.
PHPCS Inspection Configuration
PHPMD Inspection Configuration
Document Rules
PHPDocs Rules:
● Each method in project MUST contain - @param, @return, @throws tags, and short method description.
● Each property and constant in project MUST contain - @var tag, and short property description.
● Each class and interface MUST contain - @category, @package, @author, @copyright, @license, @link and
short desc.
● Each file MUST contain - @category, @package, @author, @copyright, @license, @link and NOTICE OF
LICENSE
● Each public method in observe is in the listening to a magento event MUST contain - @see with value
event_name
● All PHP files MUST start with php tag, and MUST contain a empty line in end of file without php close tag.
● Each deprecated method MUST contain - @depricated and @see tags, @see -
class_method_with_new_functionality
Postman Introduction
Postman
Postman is API development and testing tool you can download from https://www.getpostman.com/apps
Xdebug Installation
~$ sudo apt install php-xdebug
~$ sudo phpenmod xdebug && php -m | grep xdebug
~$ sudo nano /etc/php/{php-version}/mods-available/xdebug.ini
[Xdebug]
zend_extension=<full_path_to_xdebug_extension>
xdebug.remote_enable=1
xdebug.remote_host=<the host where PhpStorm is running (e.g. localhost)>
xdebug.remote_port=<the port to which Xdebug tries to connect on the host where PhpStorm is
running (default 9000)>
xdebug.remote_autostart=1
Postman Collections
A Postman Collection is an Executable API Description. With Postman collections you can:
● Publishing an API collection can be done via a Run In Postman button, embedded within the publisher’s
site, and downloading a Postman Collection directly into the developer’s Postman instance.
● API Monitoring is a scheduled service to run a Postman Collection, reporting results based on tests
embedded in the collection, and reported in the user’s Postman dashboard.
● API Documentation publishes a shareable, customized view of the API’s Postman Collection - helping
developers onboard quickly to an API.
● Developers can create a Mock Server from a collection, allowing API users to view example request &
response pairs, even before the API is complete.
● Developers can Debug APIs by creating requests, adding tests, and examining responses.
How It’s Work
Debug PHP in Docker
Our php docker image already contain Xdebug in path/to/project/docker/php-fpm.dockerfile ;
xdebug configuration are in path/to/project/docker/etc/xdebug.ini ;
PHP Environment Variables are in path/to/project/docker/php.env ;
Environment Variables used for PHP Storm and Xdebug:
XDEBUG_CONFIG=remote_host=172.17.0.1 - IDE machine IP address
PHP_IDE_CONFIG=serverName=example - server name in PHPSTORM
Get your IP address in docker network (ifconfig (Unix) or ipconfig (Win)) and put to remote_host
~$ ifconfig
docker0 Link encap:Ethernet HWaddr #########
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
param
Xdebug Configuration In Docker
Mount to the php container xdebug.ini file next content:
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=19000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
In PHP dockerfile php-fpm.dockerfile
RUN pecl install xdebug-2.5.5 
&& docker-php-ext-enable xdebug
Configure Xdebug in Storm
Configure Server
Configure Proxy
Xdebug Profiling
xdebug.profiler_enable=1 or xdebug.profiler_enable_trigger=1 and activate it by XDEBUG_PROFILE
GET/POST parameter. xdebug.profiler_output_dir=/path/to/volume/profiler_output
Useful Links
● Docker & Docker-Compose
https://docs.docker.com/docker-for-windows/
https://docs.docker.com/docker-for-windows/install/
https://kitematic.com/
https://docs.docker.com/compose/install/
https://docs.docker.com/compose/gettingstarted/
● Xdebug configuration
https://gist.github.com/chadrien/c90927ec2d160ffea9c4
https://xdebug.org/
https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
● Coding style guide
https://www.php-fig.org/psr/psr-1/
https://www.php-fig.org/psr/psr-2/
Useful Links (2)
● PHPMD & PHPCS & PHPDOCS
https://phpmd.org/rules/index.html
https://phpmd.org/download/index.html
https://github.com/squizlabs/PHP_CodeSniffer
https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm
https://confluence.jetbrains.com/display/PhpStorm/PHP+Mess+Detector+in+PhpStorm
https://www.phpdoc.org/
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
https://github.com/object-calisthenics/phpcs-calisthenics-rules
https://github.com/magento-ecg/coding-standard
https://github.com/joomla/coding-standards
● POSTMAN
https://habr.com/company/kolesa/blog/351250/
https://www.getpostman.com/

More Related Content

PPTX
PSR-7 - Middleware - Zend Expressive
PDF
Ninja Build: Simple Guide for Beginners
PDF
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
PDF
Zend expressive workshop
PDF
Golang Project Layout and Practice
PDF
Raspberry Pi + ROS
PDF
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
PDF
Statyczna analiza kodu PHP
PSR-7 - Middleware - Zend Expressive
Ninja Build: Simple Guide for Beginners
COSCUP 2016 - ROS + Gazebo機器人模擬器工作坊
Zend expressive workshop
Golang Project Layout and Practice
Raspberry Pi + ROS
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
Statyczna analiza kodu PHP

What's hot (20)

ODP
Deploying Perl apps on dotCloud
PDF
Modeling and Control Robot Arm using Gazebo, MoveIt!, ros_control
PDF
Fighting API Compatibility On Fluentd Using "Black Magic"
PDF
Middleware as Code with mruby
PDF
Modern Black Mages Fighting in the Real World
PDF
Rest, sockets em golang
ODP
Ripping web accessible .git files
PDF
Porting your favourite cmdline tool to Android
ODP
Wonderful world of (distributed) SCM or VCS
PDF
parenscript-tutorial
PDF
RubyGems 3 & 4
PPTX
Debugging Ruby (with Pry)
PDF
Import golang; struct microservice - Codemotion Rome 2015
ODP
Debugging Rails 3 Applications
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
PDF
Take care of hundred containers and not go crazy
PDF
Hijacking Ruby Syntax in Ruby
PDF
Middleware as Code with mruby
PDF
このPHP拡張がすごい!2017
Deploying Perl apps on dotCloud
Modeling and Control Robot Arm using Gazebo, MoveIt!, ros_control
Fighting API Compatibility On Fluentd Using "Black Magic"
Middleware as Code with mruby
Modern Black Mages Fighting in the Real World
Rest, sockets em golang
Ripping web accessible .git files
Porting your favourite cmdline tool to Android
Wonderful world of (distributed) SCM or VCS
parenscript-tutorial
RubyGems 3 & 4
Debugging Ruby (with Pry)
Import golang; struct microservice - Codemotion Rome 2015
Debugging Rails 3 Applications
Large-scaled Deploy Over 100 Servers in 3 Minutes
ROS Hands-On Intro/Tutorial (Robotic Vision Summer School 2015) #RVSS #ACRV
Take care of hundred containers and not go crazy
Hijacking Ruby Syntax in Ruby
Middleware as Code with mruby
このPHP拡張がすごい!2017
Ad

Similar to PHP Development Tools (20)

ODP
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
PDF
PHP QA Tools
PDF
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
KEY
Improving QA on PHP projects - confoo 2011
PPT
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
PDF
Development Workflow Tools for Open-Source PHP Libraries
PPTX
Toolbox of a Ruby Team
PDF
Using the new WordPress REST API
ODP
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
PDF
Learned lessons in a real world project
PPTX
Start tracking your ruby infrastructure
PDF
Composer Helpdesk
KEY
Php Power Tools
PDF
Automation day red hat ansible
PDF
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
PDF
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
PPTX
Docker based Architecture by Denys Serdiuk
PPTX
Go Is Your Next Language — Sergii Shapoval
PPTX
Control your deployments with Capistrano
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
PHP QA Tools
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
Improving QA on PHP projects - confoo 2011
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Development Workflow Tools for Open-Source PHP Libraries
Toolbox of a Ruby Team
Using the new WordPress REST API
Nagios Conference 2014 - Spenser Reinhardt - Detecting Security Breaches With...
Learned lessons in a real world project
Start tracking your ruby infrastructure
Composer Helpdesk
Php Power Tools
Automation day red hat ansible
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Docker based Architecture by Denys Serdiuk
Go Is Your Next Language — Sergii Shapoval
Control your deployments with Capistrano
Ad

Recently uploaded (20)

PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Geodesy 1.pptx...............................................
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Sustainable Sites - Green Building Construction
DOCX
573137875-Attendance-Management-System-original
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
PPT on Performance Review to get promotions
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Geodesy 1.pptx...............................................
CH1 Production IntroductoryConcepts.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Automation-in-Manufacturing-Chapter-Introduction.pdf
Sustainable Sites - Green Building Construction
573137875-Attendance-Management-System-original
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT on Performance Review to get promotions
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Internet of Things (IOT) - A guide to understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT

PHP Development Tools

  • 2. Why I like PHPStorm ● You can develop applications in PHP versions 5.3/5.4/5.5/5.6/7.0/7.1, SQL & PL/SQL, JavaScript, XML, HTML, CSS. ● You can add functionality to our IDE by installing plugins (Bash, Symfony, Laravel, Magento 2, NodeJS, LiveEdit, Spy-JS, Meteor). ● Support for Vagrant and Docker, Docker Compose, SSH console & remote tools. ● Databases and SQL Editor in PhpStorm (MySQL, PostgreSQL, Oracle, SQLite, etc) ● Coding style Support PSR1/PSR2, PHPDoc support. ● Version control systems integration Git, Subversion, Mercurial, Perforce, CVS, TFS ● Duplicated Code Detector. PHP Code Sniffer (phpcs) that checks for code smells on the fly. Local History. Debugging with Xdebug and ZendDebugger.
  • 3. Advantages of Using Docker Portability across machines – an application and all its dependencies can be bundled into a single container that can be transferred to another machine that runs Docker, and executed there without compatibility issues. Version control and component reuse – you can track successive versions of a container, inspect differences, or roll-back to previous versions. Sharing – you can use a remote repository to share your container with others.
  • 5. Docker Usage ~$ docker pull node:latest ~$ docker run -it --name="angular_test" node:latest /bin/bash ~$ npm install -g @angular/cli ~$ docker build -t angular-img . ~$ docker commit -m="This a test angular image" angular_test my.gitlabrepo/test_repo ~$ docker login && docker push my/test_repo
  • 6. Docker File Example FROM php:5.6-fpm RUN apt-get update && apt-get install -y libfreetype6-dev libicu-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libxslt1-dev RUN docker-php-ext-install gd mcrypt mbstring sockets zip xsl soap RUN pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug ADD ./etc/init.d/php/run.sh /run.sh RUN curl -Lsf 'https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz' | tar -C '/usr/local' -xvzf - ENV PATH /usr/local/go/bin:$PATH RUN go get github.com/mailhog/mhsendmail RUN cp /root/go/bin/mhsendmail /usr/bin/mhsendmail
  • 7. Solr Docker File FROM java:6 RUN mkdir -p /opt/solr RUN cd /tmp && curl https://archive.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz | tar xvz && mv -v apache-solr-3.6.1/* /opt/solr EXPOSE 8983 VOLUME ["/opt/solr/example/solr/data", "/opt/solr/example/solr/conf"] WORKDIR /opt/solr/example CMD java -jar start.jar
  • 8. Every Day Docker Commands ~$ docker ps -a ~$ docker stop|start|restart container_name ~$ docker run --name ubuntu -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done" ~$ docker exec -it ubuntu bash ~$ docker logs ubuntu ~$ docker history ubuntu ~$ docker stats
  • 9. Docker Search ~$ docker search node NAME DESCRIPTION STARS OFFICIAL AUTOMATED node Node.js is a JavaScript-based platform for... 5829 [OK] mhart/alpine-node Minimal Node.js built on Alpine Linux 366 mongo-express Web-based MongoDB admin interface, written... 269 [OK] nodered/node-red-docker Node-RED Docker images. 168 [OK] iojs io.js is an npm compatible platform origin... 126 [OK] prom/node-exporter 83 [OK] readytalk/nodejs Node.js based off the official Debian W
  • 10. One Line Scripts ~$ curl -s https://registry.hub.docker.com//v1/repositories/php/tags | php -r 'print_r(json_decode(file_get_contents("php://stdin")));' | grep fpm | head -20 ~$ sudo nano /usr/local/bin/docker-tags ~$ sudo chmod +x /usr/local/bin/docker-tags #!/usr/bin/env bash curl -s https://registry.hub.docker.com//v1/repositories/$1/tags | php -r 'print_r(json_decode(file_get_contents("php://stdin")));' | grep name | grep $2 | head -$3
  • 11. Docker Tags ~$ docker-tags php fpm 10 [name] => 5-fpm-alpine [name] => 5-fpm-alpine3.4 [name] => 5-fpm-alpine3.7 [name] => 5-fpm-jessie [name] => 5-fpm-stretch [name] => 5.4-fpm [name] => 5.4.35-fpm [name] => 5.4.36-fpm [name] => 5.4.37-fpm [name] => 5.4.38-fpm
  • 12. One Line Scripts PHP ~$ sudo nano /usr/local/bin/docker-tag-php #!/usr/bin/php -q <?php $repoCh = curl_init('https://registry.hub.docker.com//v1/repositories/' . $argv[1] . '/tags'); curl_setopt($repoCh, CURLOPT_RETURNTRANSFER, 1); foreach (json_decode(curl_exec($repoCh)) as $tag) { echo $tag->name . PHP_EOL; } curl_close($repoCh); ~$ sudo chmod +x /usr/local/bin/docker-tag-php
  • 13. Docker Tags PHP ~$ docker-tags-php node | grep jessie | tail -n 10 8.11-jessie 8.11.2-jessie 8.11.3-jessie 9-jessie 9.11-jessie 9.11.1-jessie 9.11.2-jessie boron-jessie carbon-jessie jessie
  • 16. docker-compose up Runs services via docker-compose util: ● db - MySql database service ● app - PHP5.6-FPM service ● web - Nginx web server ● redis - Redis session and cache storage ● mongo - Mongo NoSql storage used for price service ● rabbit - RabbitMQ queue server ● solr -Apache Solr service for fulltext search ● bps - Backend price service on Python Tornado ● fps - Frontend price service on PHP ● worker - PHP worker for background jobs ● cron - Run application schedule tasks ● mailservice - Caught all mail from application
  • 17. Docker Compose File Example version: '3' services: influx: image: influxdb volumes: - ./docker/var/lib/influx:/var/lib/influxdb - ./docker/etc/init.d/influxdb:/docker-entrypoint-initdb.d grafana: image: grafana/grafana ports: - 127.0.0.1:3000:3000 volumes: - ./docker/var/lib/grafana:/var/lib/grafana depends_on: - influx cadvisor: image: google/cadvisor ports: - 127.0.0.1:8080:8080 command: -logtostderr -docker_only -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influx:8086
  • 19. Coding style guide PSR-1 ● Files MUST use only <?php and <?= tags. ● Files MUST use only UTF-8 without BOM for PHP code. ● Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause side-effects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both. ● Namespaces and classes MUST follow an “autoloading” PSR: [PSR-0, PSR-4]. ● Class names MUST be declared in StudlyCaps. ● Class constants MUST be declared in all uppercase with underscore separators. ● Method names MUST be declared in camelCase.
  • 20. Coding style guide PSR-2 ● Code MUST use 4 spaces for indenting, not tabs. ● There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less. ● There MUST be one blank line after the namespace declaration, and there MUST be one blank line after the block of use declarations. ● Opening braces for classes MUST go on the next line, and closing braces MUST go on the next line after the body. ● Opening braces for methods MUST go on the next line, and closing braces MUST go on the next line after the body. ● Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility. ● Control structure keywords MUST have one space after them; method and function calls MUST NOT. ● Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. ● Opening parentheses for control structures MUST NOT have a space after them, and closing parentheses for control structures MUST NOT have a space before.
  • 21. File | Settings | Editor | Code Style | PHP
  • 22. PHP Code Sniffer ● WordPress-Coding-SWordPress-Coding-Standardstandards/ ● object-calisthenics/phpcs-calisthenics-rules ● yiisoft/yii2-coding-standards ● Symplify/EasyCodingStandard ● joomla/coding-standards ~$ sudo nano composer.json { "require": { "magento-ecg/coding-standard": ">=3.0", "squizlabs/php_codesniffer": "3.*" } }
  • 23. PHP CS Setup Setup PHPCS in PHPStorm: In PHPStorm open File > Settings > Languages & Frameworks> PHP > Code Sniffer Click to configuration, in opened popup click to the (+) and provide path to phpcs launcher.
  • 24. PHP MD Setup Setup PHPMD in PHPStorm: In PHPStorm open File > Settings > Languages & Frameworks> PHP > Mess Detector Click to configuration, in opened popup click to the (+) and provide path to phpmd launcher.
  • 27. Document Rules PHPDocs Rules: ● Each method in project MUST contain - @param, @return, @throws tags, and short method description. ● Each property and constant in project MUST contain - @var tag, and short property description. ● Each class and interface MUST contain - @category, @package, @author, @copyright, @license, @link and short desc. ● Each file MUST contain - @category, @package, @author, @copyright, @license, @link and NOTICE OF LICENSE ● Each public method in observe is in the listening to a magento event MUST contain - @see with value event_name ● All PHP files MUST start with php tag, and MUST contain a empty line in end of file without php close tag. ● Each deprecated method MUST contain - @depricated and @see tags, @see - class_method_with_new_functionality
  • 28. Postman Introduction Postman Postman is API development and testing tool you can download from https://www.getpostman.com/apps
  • 29. Xdebug Installation ~$ sudo apt install php-xdebug ~$ sudo phpenmod xdebug && php -m | grep xdebug ~$ sudo nano /etc/php/{php-version}/mods-available/xdebug.ini [Xdebug] zend_extension=<full_path_to_xdebug_extension> xdebug.remote_enable=1 xdebug.remote_host=<the host where PhpStorm is running (e.g. localhost)> xdebug.remote_port=<the port to which Xdebug tries to connect on the host where PhpStorm is running (default 9000)> xdebug.remote_autostart=1
  • 30. Postman Collections A Postman Collection is an Executable API Description. With Postman collections you can: ● Publishing an API collection can be done via a Run In Postman button, embedded within the publisher’s site, and downloading a Postman Collection directly into the developer’s Postman instance. ● API Monitoring is a scheduled service to run a Postman Collection, reporting results based on tests embedded in the collection, and reported in the user’s Postman dashboard. ● API Documentation publishes a shareable, customized view of the API’s Postman Collection - helping developers onboard quickly to an API. ● Developers can create a Mock Server from a collection, allowing API users to view example request & response pairs, even before the API is complete. ● Developers can Debug APIs by creating requests, adding tests, and examining responses.
  • 32. Debug PHP in Docker Our php docker image already contain Xdebug in path/to/project/docker/php-fpm.dockerfile ; xdebug configuration are in path/to/project/docker/etc/xdebug.ini ; PHP Environment Variables are in path/to/project/docker/php.env ; Environment Variables used for PHP Storm and Xdebug: XDEBUG_CONFIG=remote_host=172.17.0.1 - IDE machine IP address PHP_IDE_CONFIG=serverName=example - server name in PHPSTORM Get your IP address in docker network (ifconfig (Unix) or ipconfig (Win)) and put to remote_host ~$ ifconfig docker0 Link encap:Ethernet HWaddr ######### inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0 param
  • 33. Xdebug Configuration In Docker Mount to the php container xdebug.ini file next content: xdebug.default_enable=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_port=19000 xdebug.remote_autostart=1 xdebug.remote_connect_back=1 xdebug.idekey="PHPSTORM" In PHP dockerfile php-fpm.dockerfile RUN pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug
  • 37. Xdebug Profiling xdebug.profiler_enable=1 or xdebug.profiler_enable_trigger=1 and activate it by XDEBUG_PROFILE GET/POST parameter. xdebug.profiler_output_dir=/path/to/volume/profiler_output
  • 38. Useful Links ● Docker & Docker-Compose https://docs.docker.com/docker-for-windows/ https://docs.docker.com/docker-for-windows/install/ https://kitematic.com/ https://docs.docker.com/compose/install/ https://docs.docker.com/compose/gettingstarted/ ● Xdebug configuration https://gist.github.com/chadrien/c90927ec2d160ffea9c4 https://xdebug.org/ https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html ● Coding style guide https://www.php-fig.org/psr/psr-1/ https://www.php-fig.org/psr/psr-2/
  • 39. Useful Links (2) ● PHPMD & PHPCS & PHPDOCS https://phpmd.org/rules/index.html https://phpmd.org/download/index.html https://github.com/squizlabs/PHP_CodeSniffer https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm https://confluence.jetbrains.com/display/PhpStorm/PHP+Mess+Detector+in+PhpStorm https://www.phpdoc.org/ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards https://github.com/object-calisthenics/phpcs-calisthenics-rules https://github.com/magento-ecg/coding-standard https://github.com/joomla/coding-standards ● POSTMAN https://habr.com/company/kolesa/blog/351250/ https://www.getpostman.com/