Upload
evaldo-felipe
View
60
Download
0
Embed Size (px)
Citation preview
PHP environment Workflow / Deployment / Tools
Evaldo Felipe216 years SysAdmin 5 months DevOpsclint.solutions@evaldofelipe
Gabriel Koerich26Adm, full-stack dev & everything betweenalgorit.com.brbulldesk.com.br@gabrielmkoerich
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
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
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
Modern PHP
Laravel x Rails
Local Environment
Require mysql and php local
$ composer global require laravel/valet
$ valet park
$ valet paths
.dev
$ valet domain .etc
Valet
/** * 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');}
Production 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
Security and Optimization
Let's Monitor
CloudFlare
Nginx as Load Balancer
Static & socket.io upstreamsnginxload balancer - gabstatic content - gabcloudflare ip config pass to app - gab
DBs
Master / Slave
Write / Read
Bkp S3 using PHP or CLI
Mysql
Background Jobs
Beanstalkd queue + Supervisor
Code Quality
Travis CITravis CI - gabCode climate - gab
Code Climate
Monitors
Papertrail
Bugsnag
NewRelic
Datadog
That's it!Where is the beer? :D