DevOps in PHP environment

53
PHP environment Workflow / Deployment / Tools

Transcript of DevOps in PHP environment

Page 1: DevOps in PHP environment

PHP environment Workflow / Deployment / Tools

Page 2: DevOps in PHP environment

Evaldo Felipe216 years SysAdmin 5 months DevOpsclint.solutions@evaldofelipe

Page 3: DevOps in PHP environment

Gabriel Koerich26Adm, full-stack dev & everything betweenalgorit.com.brbulldesk.com.br@gabrielmkoerich

Page 4: DevOps in PHP environment

PHP?!

● Easy for beginners● Easy to "deploy"● PHP mixed in HTML● No conventions for

function names

Evolution

< 5.3 Lixo

5.3 Namespaces, closures (anonymous functions)

5.4 Traits, [] for arrays

5.5 OPcache, finally on try blocks

5.6 Agument unpacking (...$args)

7.0 Performance (thanks to HHVM), return types, scalar types (int, float, string, bool), improved exceptions

7.1 Nullable types (?int), catch multiple exceptions

Page 5: DevOps in PHP environment

PHP?!Community

Composer / Packagist / AutoloaderDotenvPHP FIG and PSRs

StandardsPSR 1 - Basic CodingPSR 2 - Coding Style GuidePSR 3 - Logger InterfacePSR 4 - AutoloadingPSR 5 - Caching InterfacePSR 7 - HTTP Message Interface

Page 6: DevOps in PHP environment

Laravel FrameworkReleased in 2011

Key Features

● Routes● Controllers● Service Container & Dependency Injection● Broadcasting (Pusher or socket.io)● Migrations (tables)● Eloquent ORM (sql)● Artisan command line● Queues (beanstalkd, redis, amazon sqs)● Unit Testing● Laravel Elixir for gulp and Laravel Mix for webpack

Page 7: DevOps in PHP environment

Modern PHP

Page 8: DevOps in PHP environment

Laravel x Rails

Page 9: DevOps in PHP environment

Local Environment

Page 10: DevOps in PHP environment

Require mysql and php local

$ composer global require laravel/valet

$ valet park

$ valet paths

.dev

$ valet domain .etc

Valet

Page 11: DevOps in PHP environment

/** * Determine if the driver serves the request. * * @param string $sitePath * @param string $siteName * @param string $uri * @return bool */public function serves($sitePath, $siteName, $uri){ return is_dir($sitePath.'/wp-admin');}

Page 12: DevOps in PHP environment
Page 13: DevOps in PHP environment

Production Environment

Page 14: DevOps in PHP environment
Page 15: DevOps in PHP environment
Page 16: DevOps in PHP environment
Page 17: DevOps in PHP environment
Page 18: DevOps in PHP environment

ACCEPT tcp -- 10.132.103.204 anywhere tcp dpt:mysqlACCEPT udp -- 10.132.103.204 anywhere udp dpt:mysqlACCEPT tcp -- 10.132.103.204 anywhere tcp dpt:postgresqlACCEPT udp -- 10.132.103.204 anywhere udp dpt:postgresqlACCEPT tcp -- 10.132.103.204 anywhere tcp dpt:11211ACCEPT udp -- 10.132.103.204 anywhere udp dpt:11211ACCEPT tcp -- 10.132.103.204 anywhere tcp dpt:6379ACCEPT udp -- 10.132.103.204 anywhere udp dpt:6379ACCEPT tcp -- 10.132.103.204 anywhere tcp dpt:11300ACCEPT udp -- 10.132.103.204 anywhere udp dpt:11300

Page 19: DevOps in PHP environment
Page 20: DevOps in PHP environment
Page 21: DevOps in PHP environment
Page 22: DevOps in PHP environment
Page 23: DevOps in PHP environment
Page 24: DevOps in PHP environment
Page 25: DevOps in PHP environment
Page 26: DevOps in PHP environment
Page 27: DevOps in PHP environment
Page 28: DevOps in PHP environment
Page 29: DevOps in PHP environment
Page 30: DevOps in PHP environment

Security and Optimization

Page 31: DevOps in PHP environment

Let's Monitor

Page 32: DevOps in PHP environment

CloudFlare

Page 33: DevOps in PHP environment
Page 34: DevOps in PHP environment
Page 35: DevOps in PHP environment

Nginx as Load Balancer

Page 36: DevOps in PHP environment

Static & socket.io upstreamsnginxload balancer - gabstatic content - gabcloudflare ip config pass to app - gab

Page 37: DevOps in PHP environment

DBs

Page 38: DevOps in PHP environment

Master / Slave

Write / Read

Bkp S3 using PHP or CLI

Mysql

Page 39: DevOps in PHP environment

Background Jobs

Page 40: DevOps in PHP environment

Beanstalkd queue + Supervisor

Page 41: DevOps in PHP environment

Code Quality

Page 42: DevOps in PHP environment

Travis CITravis CI - gabCode climate - gab

Page 43: DevOps in PHP environment

Code Climate

Page 44: DevOps in PHP environment

Monitors

Page 45: DevOps in PHP environment

Papertrail

Page 46: DevOps in PHP environment

Bugsnag

Page 47: DevOps in PHP environment
Page 48: DevOps in PHP environment
Page 49: DevOps in PHP environment
Page 50: DevOps in PHP environment
Page 51: DevOps in PHP environment

NewRelic

Page 52: DevOps in PHP environment

Datadog

Page 53: DevOps in PHP environment

That's it!Where is the beer? :D