There is not enough knowledge of programming languages to be good developers nowadays. It is important to understand the processes of continually improving the quality of the code and its performance. The ability to configure the development processes in a team more valuable than just writing code. To do this, you need to start using new tools or improve existing ones. We will go through all stages of development and find out what can be done better.
16. 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...
17. Save them all
$ composer require friendsofphp/php-cs-fixer --dev
$ ./vendor/bin/php-cs-fixer fix src --rules=@PSR1,@PSR2 --dry-run
--diff
19. Static code analyze
● Phpstan
● Phan
● Psalm
● Phpstorm Inspections
● Unpredictable function result
● Array shapes
● Class, method, function exists
● No syntax errors
● PhpDoc matches real types
20. 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
21. Testing
● Cover at least critical parts
● Write functional tests
● Write tests after something is broken
22.
23. API standard
● Response format
● Pagination
● Sorting
● Filtering
● Updates
● Error responses
● Library for
%framework%
25. 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