Developer’s
toolchain
Dmytro Dziubenko
PayCore.io
About me
● 3 years in Interkassa
● CTO at PayCore.io
● 10 years in production
● https://github.com/dzubchik
Local development
$ git clone git@vcs.company.name/mega-project.git
Local development
● Docker
● Docker-compose
● Task runner
● README.md
Docker
Docker-compose
$ make
IDE
● Correct php version
● IDE templates
● Hotkeys
● Refactoring
● Necessary plugins
● EditorConfig
Xdebug
Xdebug: conditions
Xdebug: dependencies
Codestyle
Codestyle diff
Do you see what really changed?
Codestyle
● PSR-1
● PSR-2
● PSR-12 (in review)
● Framework style guide
○ Symfony
○ Laravel
○ Zend
● Code should use four spaces for indenting
● Lines should be 80 characters or less
● Opening braces must go on the next line after the
function definition
● Closing braces must go on the next line after the function
body
● Control structure keywords must have one space after
them; method and function calls must not
● Boolean -> bool, integer -> int
● Class names are written using StudlyCase
● Constants - UPPERCASE_WITH_UNDERSCORE
● Function names are defined in camelCase
● Use UTF-8 encoding
● And much more...
Save them all
$ composer require friendsofphp/php-cs-fixer --dev
$ ./vendor/bin/php-cs-fixer fix src --rules=@PSR1,@PSR2 --dry-run
--diff
Codestyle
$ ./bin/php-cs-fixer fix --config=php_cs.php
Static code analyze
● Phpstan
● Phan
● Psalm
● Phpstorm Inspections
● Unpredictable function result
● Array shapes
● Class, method, function exists
● No syntax errors
● PhpDoc matches real types
Phpstan
● Easy to install
● A lot of plugins
● Zero configuration
● Can analyze a part of project
● Quick analyze
● Neon config format
● No custom annotations
● No array shapes
● No generic annotations
Testing
● Cover at least critical parts
● Write functional tests
● Write tests after something is broken
API standard
● Response format
● Pagination
● Sorting
● Filtering
● Updates
● Error responses
● Library for
%framework%
API standard
● Collection+JSON
● GraphQL
● HAL
● HATEOAS
● Hydra
● JSON API
● JSON-LD
● SIREN
JSON-API
● Easy to implement on start
● A lot of libraries
● Easy to understand
● Resource includes
● Not trivial no CRUD operations
● Hard to implement on production
● Not suitable for all data types
● Requires custom header -
application/vnd.api+json
Api specification (OpenAPI)
OpenAPI aka Swagger
● Schema
● UI
● Sandbox
● Versioning
● Code generation
Project lifecycle
Dev Ops
Database migration
● Make database dump accessible for developers
● Run migrations on CI
● Evolutionary Database Design
Error handling
● Sentry
● NewRelic
● Rollbar
Questions?
Links
● https://habr.com/ru/company/southbridge/blog/323554/
● https://habr.com/ru/company/badoo/blog/426605/
● https://fwdays.com/event/php-fwdays-2018/review/static-analysis
● https://github.com/Symplify/EasyCodingStandard
● https://github.com/php-fig/fig-standards/blob/master/proposed/extended-
coding-style-guide.md
● https://modeling-languages.com/modeling-web-api-comparing/
● https://martinfowler.com/articles/evodb.html
● https://phpstorm.tips/
● RAML
● ApiBlueprint
Symfony development

Dmytro Dziubenko "Developer's toolchain"