Slide 1

Slide 1 text

Comment améliorer le quotidien des Développeurs PHP ?

Slide 2

Slide 2 text

hello! Alexandre Jardin Senior Back-end Developer @EmakinaFR

Slide 3

Slide 3 text

Most Common Problems Local environment used for development not reliable Same commands used again and again every day Too much time spent by the team when reviewing the code

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

1. Docker Let’s start with your computer

Slide 6

Slide 6 text

Containers VS Virtual Machines

Slide 7

Slide 7 text

Why?

Slide 8

Slide 8 text

Multiple projects = Multiple configurations

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Resources used by VMs

Slide 11

Slide 11 text

How?

Slide 12

Slide 12 text

docker-compose.yml “apache” service on port 443 with a shared volume for project code “mysql” service on port 3306 with a persistent volume for databases

Slide 13

Slide 13 text

Dockerfile Base Custom packages Custom configuration

Slide 14

Slide 14 text

Migration from PHP 5.6 to PHP 7.2 -FROM php:5.6-fpm +FROM php:7.2-fpm docker-php-ext-install -j$(nproc) \ […] - mcrypt \ […] + yes "" | pecl install apcu-4.0.11 lzf mongo redis && \ + docker-php-ext-enable apcu lzf mongo redis && \ - yes "" | pecl install apcu lzf mongodb redis && \ - docker-php-ext-enable apcu lzf mongodb redis && \

Slide 15

Slide 15 text

Symfony Recipes ✘ Docker support in progress ✘ Environment managed by the community ✘ Symfony + Composer + Docker = https://github.com/symfony/flex/pull/128

Slide 16

Slide 16 text

Summary ✘ Same environment for each developer ✘ Can be shared with the project source ✘ Light & Fast! Less time wasted on your environment, more time to develop things.

Slide 17

Slide 17 text

2. Code Styles Focus on substance over form

Slide 18

Slide 18 text

Why?

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

“ Programs must be written for people to read, and only incidentally for machines to execute. Abelson & Sussman

Slide 21

Slide 21 text

How?

Slide 22

Slide 22 text

PHP-CS-Fixer

Slide 23

Slide 23 text

ESLint

Slide 24

Slide 24 text

Summary ✘ Code more readable ✘ Commits more relevant ✘ Code (sometimes) more efficient No matter what rules you choose, consistency is the key.

Slide 25

Slide 25 text

3. Static Analysis How about (almost) automate the code review?

Slide 26

Slide 26 text

Why?

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Time spent by developers from Codacy studies Code review

Slide 29

Slide 29 text

How?

Slide 30

Slide 30 text

IDE real-time analysis

Slide 31

Slide 31 text

PHP Static Analysis Tool (PHPStan)

Slide 32

Slide 32 text

Symfony Linters ✘ Built-in commands ✘ Are able to detect syntax errors ✘ Almost instant

Slide 33

Slide 33 text

External Services ✘ Codacy ✘ Scrutinizer ✘ SonarQube ✘ SensioLabsInsight ✘ ...

Slide 34

Slide 34 text

Codacy Dashboard Bitbucket integration

Slide 35

Slide 35 text

Summary ✘ Better autonomy of team members ✘ Positive impact on the overall project quality ✘ Nice learning process Free or Premium? Choose one or both, it's a must-have!

Slide 36

Slide 36 text

4. Security Audits Are you sure your dependencies are secure?

Slide 37

Slide 37 text

Why?

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Composer = Tons of dependencies

Slide 40

Slide 40 text

83,245,467 Number of composer.lock files checked since 2014 22,106,532 Total number of vulnerabilities found 7,294,964 = 9% Number of composer.lock files with known vulnerabilities

Slide 41

Slide 41 text

How?

Slide 42

Slide 42 text

Roave Security Advisories or SensioLabs Security Checker

Slide 43

Slide 43 text

Symfony Security Monitoring

Slide 44

Slide 44 text

Summary ✘ Easy to integrate ✘ Maintained by the community ✘ Can be part of a “quality package” Nobody wants a security breach in its application...

Slide 45

Slide 45 text

5. Makefile Let's automate a few things

Slide 46

Slide 46 text

Why?

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

Daily work = Tons of commands

Slide 49

Slide 49 text

Bash aliases

Slide 50

Slide 50 text

How?

Slide 51

Slide 51 text

Overview

Slide 52

Slide 52 text

Summary ✘ Shared with the project source ✘ Easy to write/maintain ✘ Can be used to share knowledge Tired of writing a command over and over? Add it in your Makefile!

Slide 53

Slide 53 text

6. Git Hooks Still too many commands?

Slide 54

Slide 54 text

Why?

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Makefile = Fewer commands

Slide 57

Slide 57 text

How?

Slide 58

Slide 58 text

Default templates

Slide 59

Slide 59 text

“commit-msg” example

Slide 60

Slide 60 text

Summary ✘ Can perform additional checks ✘ Can trigger additional processes ✘ Work with any programming language With custom hooks, Git can fit nearly any workflow you can imagine.

Slide 61

Slide 61 text

7. Blackfire Because performance matters

Slide 62

Slide 62 text

Why?

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

“ 53% of users abandon a website that takes more than 3 seconds to load. Google studies

Slide 65

Slide 65 text

Clean code !== Fast code

Slide 66

Slide 66 text

How?

Slide 67

Slide 67 text

Profile example

Slide 68

Slide 68 text

Metrics/Tests example

Slide 69

Slide 69 text

Scenarios example

Slide 70

Slide 70 text

Real examples from a legacy project

Slide 71

Slide 71 text

Summary ✘ Very easy to install and use ✘ Performance profiling and recommendations ✘ Can also be used for non-regression testing Before upgrading your infrastructure, have a look to Blackfire!

Slide 72

Slide 72 text

“Never stop measuring” Nicolas Grekas

Slide 73

Slide 73 text

Overview Docker Code Styles Static Analysis Security Makefile Git Hooks Blackfire

Slide 74

Slide 74 text

thanks! Any questions? Email: [email protected] GitHub: ajardin // Twitter: alxjrdn