Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Heroku und PHP
Search
Christoph Hochstrasser
November 07, 2013
Programming
0
130
Heroku und PHP
Slides from my talk at the Developer Conference 2013 in Hamburg. Not affiliated with Heroku.
Christoph Hochstrasser
November 07, 2013
Tweet
Share
More Decks by Christoph Hochstrasser
See All by Christoph Hochstrasser
VILT Stack (DevTreff Amstetten)
hochchristoph
0
66
Git Workshop @ Makerspace[A]
hochchristoph
0
46
Einstieg in Open Source
hochchristoph
0
100
Nuxt – Die Zukunft der Webentwicklung
hochchristoph
0
110
Nuxt – The Future of Web Frameworks
hochchristoph
0
32
Design Essentials für Techniker
hochchristoph
1
39
Look, no database
hochchristoph
0
240
7 Things Learned
hochchristoph
0
26
Einführung in Go
hochchristoph
0
60
Other Decks in Programming
See All in Programming
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
1
420
生成AIで日々のエラー調査を進めたい
yuyaabo
0
640
Effect の双対、Coeffect
yukikurage
5
1.4k
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1k
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
290
FormFlow - Build Stunning Multistep Forms
yceruto
1
190
VS Code Update for GitHub Copilot
74th
1
310
A2A プロトコルを試してみる
azukiazusa1
2
1.1k
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
660
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
170
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
570
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
We Have a Design System, Now What?
morganepeng
53
7.7k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Raft: Consensus for Rubyists
vanstee
140
7k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Transcript
Heroku & PHP
Sponsored by Heroku Not.
Christoph Hochstrasser @hochchristoph github.com/CHH Blog: christophh.net Full-Stack Web Developer –
Funemployed Contributor zu Composer, StackPHP. Creator von php-build.
Um was gehts? • Was ist Heroku? • Das Problem
mit Heroku und PHP • Buildpacks & Open Source to the rescue! • Rezepte für PHP Apps auf Heroku
Heroku? Wat?
None
her-OH-koo
Platform as a Service
Ruby, Python, Node.js, Java, Scala, Clojure, Go
(PHP) dazu später mehr
Dynos
Addons addons.heroku.com
„Buildpacks“
12factor.net
PHP
PHP Support auf Heroku ist „solala“
Problem:
PHP 5.3 + Apache Prefork MPM & mod_php + Dynos
haben nur 512MB RAM
Aber das können wir beheben. Let’s do it.
Buildpack • Erlaubt die Verwendung eines eigenen Software Stacks auf
Heroku • Pro App • Git Repository • Scripts (detect, compile, release) • Binaries von z.B. S3 • Mehr unter https://devcenter.heroku.com/articles/buildpack- api
Buildpack git push heroku master detect compile release
Darf ich vorstellen: github.com/CHH/heroku-buildpack-php
Inspiriert vom Node.js Buildpack
Moderner PHP Stack
PHP-FPM & NGINX
PHP 5.3, 5.4, 5.5 dynamisch konfigurierbar
Zend Opcache
mongo redis intl pgsql apcu + more to come
<?php phpinfo(); ?> https://chh-php-test.herokuapp.com/info
Composer
Unterstützt Symfony 2, Silex & Slim Wordpress (mit Anpassungen) In
Zukunft auch Zend Framework 1/2 & Laravel
NewRelic Monitoring
Konfiguration über composer.json
{ "require": { "php": ">=5.3.0", "silex/silex": "~1.0@dev", "ext-libevent": "*" },
"extra": { "heroku": { "document-root": "web", "index-document": "index.php", "php-config": [ "short_open_tag=on", "date.timezone=Europe/Vienna", "newrelic.appname=php-test" ], "engines": { "php": "5.4.*", "nginx": "1.4.*" }, "compile": [ ] } } } Framework php.ini Einstellungen Stack Versionen Shell Befehle Häufige Settings
„Zeroconf“ Symfony 2 Support
$ php composer.phar create-project symfony/framework-standard-edition Symfony 2.3.0 $ cd Symfony
$ heroku create —buildpack git://github.com/CHH/heroku-buildpack-php —region eu $ git push heroku master
Help Wanted! ! github.com/CHH/heroku-buildpack-php/issues
Rezepte
Lokales Development
php -S php app/console server:run
Credentials
Config Vars $ heroku config:set API_SECRET=mytotallysecretkey $_SERVER['API_SECRET']
+ änderbar ohne Code Push + nicht eingecheckt im Repository
Kandidaten für Config Vars: • S3 Bucket • Amazon Access
Key/Secret • Datenbank Host, Port, Username, Passwort, Datenbankname • Redis Host • Secrets aller Art (Facebook,…) • Application Environment
Aber wie mach ich das lokal?
.env github.com/vlucas/phpdotenv
AWS_SECRET_KEY=foo AWS_ACCESS_KEY_ID=asd8asd8ausd MY_AWESOME_CONF_VAR=foobarbaz DATABASE_URL=mysql://root:pass@localhost:6657/dbname SERVICE_URL=localhost:5000 REDIS_URL=redis://localhost:6379 REDIS_PASS=s3cr3tp4ss SERVER_NAME=localhost:3000 APP_ENV=development
Assets
JS/CSS/Images → S3 → CDN
Alternative php app/console assets:dump —env=prod
{ … "extra": { "heroku": { … "compile": [ "php
app/console assets:dump —env=prod" ] } } }
Sessions
Redis $ heroku addons:add redistogo
Datenbank
Heroku Postgres heroku addons:add heroku-postgresql
MySQL: Amazon RDS heroku addons:add amazon_rds
MongoDB $ heroku addons:add mongohq
Links • Heroku PHP Buildpack: github.com/CHH/heroku-buildpack-php • Heroku Buildpacks API:
https://devcenter.heroku.com/articles/ buildpack-api • HHVM Buildpack: https://github.com/hhvm/heroku-buildpack-hhvm
Danke!
Alle Klarheiten beseitigt? Fragen?