SlideShare a Scribd company logo
Rapid Prototyping Chatter with a 
PHP/Hack Canvas App on Heroku 
Rodney White 
President, The Acceleration Agency 
@rodney_white
The goal is to provide a process 
and framework to rapidly prototype 
Force.com Chatter Canvas apps within 
minutes, not days or months
Agenda 
1. Introduction 
2. Rapid Prototyping Basics 
3. Tech Basics 
4. Time to code 
5. Questions
Rodney White 
Founder, The Acceleration Agency
The Acceleration Agency leverages 
iterative philosophies and methodologies to 
innovate new products, platforms, and services. 
We are Designers. 
We are Makers. 
We are Learners.
to 
a 
video, 
Rapid Prototyping Basics
Rapid Prototyping Basics* 
Maximize the Rate of Learning by 
Minimizing the time to try ideas 
- Tom Chi 
Rule #1: Find the quickest path to the experience. 
Rule #2: Making is the best kind of thinking. 
Rule #3: Use materials that move at the speed of thought. 
Rule #4: Your user’s reality is the medium. 
Rule #5: Knowing is the enemy of learning. 
Rule #6: “The first draft of anything is shit.” - Ernest Hemingway 
* Some rules are courtesy of Tom Chi. Please watch: https://www.youtube.com/watch?v=DkyMCCnNI3Q to learn more
Rapid Prototyping Basics* 
Rate based goals 
By the time you try 1 iteration 
-> 5% chance of success 
By the time you try 20 iterations 
-> 64% chance of success 
By the time you try 50 iterations 
-> 92% chance of success
to 
a 
video, 
Chatter Basics
Chatter Basics 
Publisher 
Chatter lets you create instant actions that 
are instantly mobile. For any business 
process. Expense reports, support cases, 
orders, and more. Customize actions for your 
company, and even integrate third party 
apps. So you can get more done in the feed 
from any device.
Chatter Basics 
Feeds and Feed Items 
Do everything in the feed. Keep up with 
critical projects, topics, and teams. Work 
together on sales opportunities, service 
cases, and marketing campaigns. Capture 
organizational knowledge in a single 
location. Drive progress from anywhere.
to 
a 
video, 
Canvas App Basics
Canvas App Basics 
With the force.com Canvas SDK, 
you can now integrate your Web 
app with the trusted salesforce.com 
platform: Your language, your code 
- Salesforce
Canvas App Basics 
Setup -> App Setup -> Create -> Apps -> Connected App -> New Button 
Enable 
Publisher, Feed, and 
VF page access 
During Prototype 
Allow 
Full access 
Enable 
oAuth 
Enable 
Canvas 
Enable 
Signed Request
Canvas App Basics 
Setup -> App Setup -> Create -> Apps -> Global Actions -> Actions -> New Action Button 
Choose 
Custom Canvas
Canvas App Basics 
Setup -> App Setup -> Create -> Apps -> Global Actions -> Publisher Layouts -> Edit Action 
Drag new action 
to Publisher Actions
Canvas App Basics 
New canvas app action is 
now 
available Chatter
Canvas App Basics 
iFrame of the canvas app 
in the publisher 
iFrame of the canvas app 
in the feed
to 
a 
video, 
Heroku Basics
Heroku Basics 
Heroku 
is a cloud platform as a service 
supporting several programming 
languages. Heroku was acquired by 
Salesforce.com in 2010.
Heroku Basics 
Heroku 
With Heroku, Developers may now deploy 
distributed and scalable code in minutes.
Heroku Basics 
Terminology 
- Procfiles - named commands that you may want executed. 
- Applications - consist of your source code, a description of any dependencies, 
and a Procfile. 
- Slug - is an application bundle of your source, fetched dependencies, the language 
runtime, and compiled/generated output of the build system - ready for execution. 
- Buildpacks - lie behind the slug compilation process. Buildpacks take your 
application, its dependencies, and the language runtime, and produce slugs. 
- Dynos - are isolated, virtualized Unix containers, that provide the environment 
required to run an application.
Heroku Basics 
As of May 2014, Heroku now offers an official PHP buildpack which supports: 
Packaging via Composer 
First class frameworks 
- Symfony 
- Laravel 
Heroku XL Support 
PHP 5.5 Support 
HHVM/HACK 3.2 Support 
NGINX Support 
Apache Support
Heroku Basics 
Enabling HHVM + NGINX 
Available procfiles 
heroku-hhvm-apache2 
heroku-hhvm-nginx 
heroku-php-apache2 
heroku-php-nginx 
Procfile example for nginx+hhvm 
$ echo 'web: vendor/bin/heroku-hhvm-nginx' > Procfile
to 
a 
video, 
Time To Code!
Time To Code! 
Sample App 1 
Hello World of Heroku
Time To Code! 
Hello World on heroku 
echo '<?php echo "Hello World!"; ?>' > index.php 
echo '{}' > composer.json 
git init 
git add . 
git commit -m "Initial import of Hello Heroku" 
heroku create 
git push heroku master 
heroku open 
http://taa.io/df14/app1/
Time To Code! 
Hello World 1.1 on heroku (with HHVM/NGINX support) 
This enables HHVM/HACK on heroku! 
echo '<?php phpinfo();' > index.php 
echo '{"require": {"php": "*","hhvm": ">= 3.1"}}' > composer.json 
echo 'web: vendor/bin/heroku-hhvm-nginx' > Procfile 
git init 
git add . 
git commit -m "Initial import of Hello Heroku" 
heroku create 
git push heroku master 
heroku open 
http://taa.io/df14/app1/
Time To Code! 
Hello World 1.1 
Let’s try it in the terminal 
http://taa.io/df14/app1/
Time To Code! 
Sample App 2 
Parse Force.com signed requests 
Proper Folder Structure
Time To Code! 
Parsing Force.com signed requests 
PHP/Hack on Heroku 
Signed 
Request 
Force.com 
Signed Request 
http://taa.io/df14/app2/
Time To Code! 
Parsing Signed request from Force.com 
// lifted from https://github.com/joshbirk/Canvas-PHP Canvas via SignedRequest/POST, the authentication should be passed via the signed_request header 
$signedRequest = @$_REQUEST['signed_request']; 
$consumer_secret = @$_ENV['consumer_secret']; 
if ($signedRequest == null || $consumer_secret == null) { 
echo "Error: Signed Request or Consumer Secret not found"; 
exit; 
} 
//decode the signedRequest 
$sep = strpos($signedRequest, '.'); 
$encodedSig = substr($signedRequest, 0, $sep); 
$encodedEnv = substr($signedRequest, $sep + 1); 
$calcedSig = base64_encode(hash_hmac("sha256", $encodedEnv, $consumer_secret, true)); 
if ($calcedSig != $encodedSig) { 
echo "Error: Signed Request Failed. Is the app in Canvas?"; 
exit; 
} 
//decode the signedRequest 
$sep = strpos($signedRequest, '.'); 
$encodedSig = substr($signedRequest, 0, $sep); 
$encodedEnv = substr($signedRequest, $sep + 1); 
//decode the signed request object 
$req = json_decode(base64_decode($encodedEnv)); 
//As of Spring '13: SignedRequest has a client object which holds the pertinent authentication info 
$access_token = $req->client->oauthToken; 
$instance_url = $req->client->instanceUrl; 
$_SFDC_REQ = $req; 
error_log(json_encode($_SFDC_REQ)); 
$location = @$req->context->environment->displayLocation; 
http://taa.io/df14/app2/
Time To Code! 
Integrating with Force.com signed requests 
- Using composer for package management 
- Configure NGINX via Procfile 
- Proper folder structure and router 
- Parse Force.com signed requests 
Folder Structure 
Public —static files (i.e. js/css files) 
Handlers — i.e. controllers’ish 
canvas — a handler for a canvas app 
Views — presentation layer (mustache templates) 
Webroot — entry point for web request 
Nginx.conf — custom config for nginx 
Procfile — custom config to enable nginx + hhvm 
http://taa.io/df14/app2/
Time To Code! 
- A few local dev gotchas 
- Localhost mock for heroku's $_ENV config 
- config.ini + parse_ini_file() 
if (php_sapi_name() == 'cli-server') { 
$ini_array = @parse_ini_file(__DIR__."/../config.ini"); 
foreach($ini_array as $key => $value){ 
$_ENV[$key] = $value; 
} 
} 
http://taa.io/df14/app2/
Time To Code! 
- A few local dev gotchas 
- https://localhost/ 
- NodeJS + NPM to the rescue 
var fs = require('fs'); 
var http = require(‘http'), httpProxy = require(‘http-proxy'); 
httpProxy.createServer({ 
target: { 
host: 'localhost', 
port: 80 
}, 
ssl: { 
key: fs.readFileSync('keys/server.key', 'utf8'), 
cert: fs.readFileSync('keys/server.crt', 'utf8') 
} 
}).listen(443); 
http://taa.io/df14/app2/
Time To Code! 
Sample App 2 
See it in Action 
http://taa.io/df14/app2/
Time To Code! 
Sample App 2 
http://taa.io/df14/app2/
Time To Code! 
Sample App 3 
Let’s build something…A Babel Fish* 
* Thanks Douglas Adams
Time To Code! 
Let’s build something…A Babel Fish 
Three parts to the Babel Fish chatter app 
- Publisher 
- Text Input 
- Feed Item 
- Dynamic translation 
- Integration with 3rd party api 
- Google Translate API 
* bonus: VisualForce integration with a Canvas App
Time To Code! 
Sample App 3 (A Babel Fish) 
See it in Action
Time To Code! 
Sample App 3 (A Babel Fish) 
Words into the 
babel fish 
Auto Translated into 
native language
Sample App 3 
(A Babel Fish on a Visual Force Page) 
Time To Code! 
Subject of the Case 
Auto Translated into 
native language
Sample App 3 (A Babel Fish) 
Want an installable AppExchange version? 
http://taa.io/df14/translator/ 
Time To Code!
Time To Code! 
Sample App 4 
Let’s build something…Voice Memo 
(Chrome and Firefox only)
Time To Code! 
Let’s build something…Voice Memos 
Three parts to the VoiceMemo chatter app 
- Publisher 
- HTML5 Audio Input 
- Feed Item 
- Audio Playback 
- Integration with 3rd party persistence layer (S3) 
- CDN playback
Time To Code! 
Sample App 4 (Voice Memo) 
See it in Action
Time To Code! 
Sample App 4 (Voice Memo) 
Record the Voice memo 
with HTML5 only 
(Chrome/Firefox only) 
Audio Playback 
in the feed
Sample App 4 (Voice Memo) 
Want an installable AppExchange version?* 
*? 
http://taa.io/df14/voicememo/ 
*No commercial support 
Time To Code!
Rodney White 
Rodney White 
@rodney_white 
rodney@taa.io 
Want the framework? 
http://taa.io/df14/
Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku

More Related Content

PPTX
Automated Deployment With Phing
PPTX
Optimizing Spring Boot apps for Docker
PDF
Php Dependency Management with Composer ZendCon 2016
ODP
PHP Quality Assurance Workshop PHPBenelux
PPTX
Application Deployment with Zend Server 5.5 beta
PDF
Zend Framework 1.8 workshop
PPTX
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
PDF
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
Automated Deployment With Phing
Optimizing Spring Boot apps for Docker
Php Dependency Management with Composer ZendCon 2016
PHP Quality Assurance Workshop PHPBenelux
Application Deployment with Zend Server 5.5 beta
Zend Framework 1.8 workshop
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...

What's hot (20)

PDF
Composer - The missing package manager for PHP
KEY
Ant vs Phing
PDF
Dependency Management with Composer
ODP
Vagrant move over, here is Docker
KEY
Plack perl superglue for web frameworks and servers
PDF
Phing: Building with PHP
PDF
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
PDF
Dockerfiles building docker images automatically v (workdir, env, add, and ...
PDF
Composer for Busy Developers - php|tek13
PPTX
Modern Perl for the Unfrozen Paleolithic Perl Programmer
PDF
How to Submit a plugin to WordPress.org Repository
PDF
Choosing the Right Framework for Running Docker Containers in Prod
PDF
Distributing UI Libraries: in a post Web-Component world
PPTX
Composer for Magento 1.x and Magento 2
PDF
Deploying PHP applications with Phing
PDF
Practical PHP Deployment with Jenkins
PDF
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
PDF
Modern Web Application Development Workflow - web2day 2014
PPTX
PHP Dependency Management with Composer
Composer - The missing package manager for PHP
Ant vs Phing
Dependency Management with Composer
Vagrant move over, here is Docker
Plack perl superglue for web frameworks and servers
Phing: Building with PHP
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
Dockerfiles building docker images automatically v (workdir, env, add, and ...
Composer for Busy Developers - php|tek13
Modern Perl for the Unfrozen Paleolithic Perl Programmer
How to Submit a plugin to WordPress.org Repository
Choosing the Right Framework for Running Docker Containers in Prod
Distributing UI Libraries: in a post Web-Component world
Composer for Magento 1.x and Magento 2
Deploying PHP applications with Phing
Practical PHP Deployment with Jenkins
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Modern Web Application Development Workflow - web2day 2014
PHP Dependency Management with Composer

Similar to Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku (20)

PPTX
Tutorial 1: Your First Science App - Araport Developer Workshop
PDF
Software Quality Assurance Tooling - Wintersession 2024
PDF
Scaleable PHP Applications in Kubernetes
PPTX
Phonegap android angualr material design
PDF
Unleash your Symfony projects with eZ Platform
PPTX
Fullstack workshop
PDF
Developing FirefoxOS
PPTX
Flutter festival gdsc juet guna
PDF
Developing applications with Hyperledger Fabric SDK
PPTX
LVPHP.org
PDF
DevOPS training - Day 1/2
PPTX
GoogleDSC_ GHRCE_ flutter_firebase.pptx
PDF
Comment améliorer le quotidien des Développeurs PHP ?
PDF
Docker for developers on mac and windows
PPT
Getting Started with Adobe AIR 1.5
PPTX
flutterbootcamp
PPTX
flutter_bootcamp_MUGDSC_Presentation.pptx
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
PDF
The Modern Developer Toolbox
PPTX
Flutter for web
Tutorial 1: Your First Science App - Araport Developer Workshop
Software Quality Assurance Tooling - Wintersession 2024
Scaleable PHP Applications in Kubernetes
Phonegap android angualr material design
Unleash your Symfony projects with eZ Platform
Fullstack workshop
Developing FirefoxOS
Flutter festival gdsc juet guna
Developing applications with Hyperledger Fabric SDK
LVPHP.org
DevOPS training - Day 1/2
GoogleDSC_ GHRCE_ flutter_firebase.pptx
Comment améliorer le quotidien des Développeurs PHP ?
Docker for developers on mac and windows
Getting Started with Adobe AIR 1.5
flutterbootcamp
flutter_bootcamp_MUGDSC_Presentation.pptx
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
The Modern Developer Toolbox
Flutter for web

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
PDF
Local development with Open Source Base Components
PPTX
TrailheaDX India : Developer Highlights
PDF
Why developers shouldn’t miss TrailheaDX India
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
PPTX
Enterprise-grade UI with open source Lightning Web Components
PPTX
TrailheaDX and Summer '19: Developer Highlights
PDF
Live coding with LWC
PDF
Lightning web components - Episode 4 : Security and Testing
PDF
LWC Episode 3- Component Communication and Aura Interoperability
PDF
Lightning web components episode 2- work with salesforce data
PDF
Lightning web components - Episode 1 - An Introduction
PDF
Migrating CPQ to Advanced Calculator and JSQCP
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
PDF
Modern Development with Salesforce DX
PDF
Get Into Lightning Flow Development
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Local development with Open Source Base Components
TrailheaDX India : Developer Highlights
Why developers shouldn’t miss TrailheaDX India
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Converting Aura Components to Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
TrailheaDX and Summer '19: Developer Highlights
Live coding with LWC
Lightning web components - Episode 4 : Security and Testing
LWC Episode 3- Component Communication and Aura Interoperability
Lightning web components episode 2- work with salesforce data
Lightning web components - Episode 1 - An Introduction
Migrating CPQ to Advanced Calculator and JSQCP
Scale with Large Data Volumes and Big Objects in Salesforce
Replicate Salesforce Data in Real Time with Change Data Capture
Modern Development with Salesforce DX
Get Into Lightning Flow Development
Integrate CMS Content Into Lightning Communities with CMS Connect

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Understanding_Digital_Forensics_Presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Empathic Computing: Creating Shared Understanding

Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku

  • 1. Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku Rodney White President, The Acceleration Agency @rodney_white
  • 2. The goal is to provide a process and framework to rapidly prototype Force.com Chatter Canvas apps within minutes, not days or months
  • 3. Agenda 1. Introduction 2. Rapid Prototyping Basics 3. Tech Basics 4. Time to code 5. Questions
  • 4. Rodney White Founder, The Acceleration Agency
  • 5. The Acceleration Agency leverages iterative philosophies and methodologies to innovate new products, platforms, and services. We are Designers. We are Makers. We are Learners.
  • 6. to a video, Rapid Prototyping Basics
  • 7. Rapid Prototyping Basics* Maximize the Rate of Learning by Minimizing the time to try ideas - Tom Chi Rule #1: Find the quickest path to the experience. Rule #2: Making is the best kind of thinking. Rule #3: Use materials that move at the speed of thought. Rule #4: Your user’s reality is the medium. Rule #5: Knowing is the enemy of learning. Rule #6: “The first draft of anything is shit.” - Ernest Hemingway * Some rules are courtesy of Tom Chi. Please watch: https://www.youtube.com/watch?v=DkyMCCnNI3Q to learn more
  • 8. Rapid Prototyping Basics* Rate based goals By the time you try 1 iteration -> 5% chance of success By the time you try 20 iterations -> 64% chance of success By the time you try 50 iterations -> 92% chance of success
  • 9. to a video, Chatter Basics
  • 10. Chatter Basics Publisher Chatter lets you create instant actions that are instantly mobile. For any business process. Expense reports, support cases, orders, and more. Customize actions for your company, and even integrate third party apps. So you can get more done in the feed from any device.
  • 11. Chatter Basics Feeds and Feed Items Do everything in the feed. Keep up with critical projects, topics, and teams. Work together on sales opportunities, service cases, and marketing campaigns. Capture organizational knowledge in a single location. Drive progress from anywhere.
  • 12. to a video, Canvas App Basics
  • 13. Canvas App Basics With the force.com Canvas SDK, you can now integrate your Web app with the trusted salesforce.com platform: Your language, your code - Salesforce
  • 14. Canvas App Basics Setup -> App Setup -> Create -> Apps -> Connected App -> New Button Enable Publisher, Feed, and VF page access During Prototype Allow Full access Enable oAuth Enable Canvas Enable Signed Request
  • 15. Canvas App Basics Setup -> App Setup -> Create -> Apps -> Global Actions -> Actions -> New Action Button Choose Custom Canvas
  • 16. Canvas App Basics Setup -> App Setup -> Create -> Apps -> Global Actions -> Publisher Layouts -> Edit Action Drag new action to Publisher Actions
  • 17. Canvas App Basics New canvas app action is now available Chatter
  • 18. Canvas App Basics iFrame of the canvas app in the publisher iFrame of the canvas app in the feed
  • 19. to a video, Heroku Basics
  • 20. Heroku Basics Heroku is a cloud platform as a service supporting several programming languages. Heroku was acquired by Salesforce.com in 2010.
  • 21. Heroku Basics Heroku With Heroku, Developers may now deploy distributed and scalable code in minutes.
  • 22. Heroku Basics Terminology - Procfiles - named commands that you may want executed. - Applications - consist of your source code, a description of any dependencies, and a Procfile. - Slug - is an application bundle of your source, fetched dependencies, the language runtime, and compiled/generated output of the build system - ready for execution. - Buildpacks - lie behind the slug compilation process. Buildpacks take your application, its dependencies, and the language runtime, and produce slugs. - Dynos - are isolated, virtualized Unix containers, that provide the environment required to run an application.
  • 23. Heroku Basics As of May 2014, Heroku now offers an official PHP buildpack which supports: Packaging via Composer First class frameworks - Symfony - Laravel Heroku XL Support PHP 5.5 Support HHVM/HACK 3.2 Support NGINX Support Apache Support
  • 24. Heroku Basics Enabling HHVM + NGINX Available procfiles heroku-hhvm-apache2 heroku-hhvm-nginx heroku-php-apache2 heroku-php-nginx Procfile example for nginx+hhvm $ echo 'web: vendor/bin/heroku-hhvm-nginx' > Procfile
  • 25. to a video, Time To Code!
  • 26. Time To Code! Sample App 1 Hello World of Heroku
  • 27. Time To Code! Hello World on heroku echo '<?php echo "Hello World!"; ?>' > index.php echo '{}' > composer.json git init git add . git commit -m "Initial import of Hello Heroku" heroku create git push heroku master heroku open http://taa.io/df14/app1/
  • 28. Time To Code! Hello World 1.1 on heroku (with HHVM/NGINX support) This enables HHVM/HACK on heroku! echo '<?php phpinfo();' > index.php echo '{"require": {"php": "*","hhvm": ">= 3.1"}}' > composer.json echo 'web: vendor/bin/heroku-hhvm-nginx' > Procfile git init git add . git commit -m "Initial import of Hello Heroku" heroku create git push heroku master heroku open http://taa.io/df14/app1/
  • 29. Time To Code! Hello World 1.1 Let’s try it in the terminal http://taa.io/df14/app1/
  • 30. Time To Code! Sample App 2 Parse Force.com signed requests Proper Folder Structure
  • 31. Time To Code! Parsing Force.com signed requests PHP/Hack on Heroku Signed Request Force.com Signed Request http://taa.io/df14/app2/
  • 32. Time To Code! Parsing Signed request from Force.com // lifted from https://github.com/joshbirk/Canvas-PHP Canvas via SignedRequest/POST, the authentication should be passed via the signed_request header $signedRequest = @$_REQUEST['signed_request']; $consumer_secret = @$_ENV['consumer_secret']; if ($signedRequest == null || $consumer_secret == null) { echo "Error: Signed Request or Consumer Secret not found"; exit; } //decode the signedRequest $sep = strpos($signedRequest, '.'); $encodedSig = substr($signedRequest, 0, $sep); $encodedEnv = substr($signedRequest, $sep + 1); $calcedSig = base64_encode(hash_hmac("sha256", $encodedEnv, $consumer_secret, true)); if ($calcedSig != $encodedSig) { echo "Error: Signed Request Failed. Is the app in Canvas?"; exit; } //decode the signedRequest $sep = strpos($signedRequest, '.'); $encodedSig = substr($signedRequest, 0, $sep); $encodedEnv = substr($signedRequest, $sep + 1); //decode the signed request object $req = json_decode(base64_decode($encodedEnv)); //As of Spring '13: SignedRequest has a client object which holds the pertinent authentication info $access_token = $req->client->oauthToken; $instance_url = $req->client->instanceUrl; $_SFDC_REQ = $req; error_log(json_encode($_SFDC_REQ)); $location = @$req->context->environment->displayLocation; http://taa.io/df14/app2/
  • 33. Time To Code! Integrating with Force.com signed requests - Using composer for package management - Configure NGINX via Procfile - Proper folder structure and router - Parse Force.com signed requests Folder Structure Public —static files (i.e. js/css files) Handlers — i.e. controllers’ish canvas — a handler for a canvas app Views — presentation layer (mustache templates) Webroot — entry point for web request Nginx.conf — custom config for nginx Procfile — custom config to enable nginx + hhvm http://taa.io/df14/app2/
  • 34. Time To Code! - A few local dev gotchas - Localhost mock for heroku's $_ENV config - config.ini + parse_ini_file() if (php_sapi_name() == 'cli-server') { $ini_array = @parse_ini_file(__DIR__."/../config.ini"); foreach($ini_array as $key => $value){ $_ENV[$key] = $value; } } http://taa.io/df14/app2/
  • 35. Time To Code! - A few local dev gotchas - https://localhost/ - NodeJS + NPM to the rescue var fs = require('fs'); var http = require(‘http'), httpProxy = require(‘http-proxy'); httpProxy.createServer({ target: { host: 'localhost', port: 80 }, ssl: { key: fs.readFileSync('keys/server.key', 'utf8'), cert: fs.readFileSync('keys/server.crt', 'utf8') } }).listen(443); http://taa.io/df14/app2/
  • 36. Time To Code! Sample App 2 See it in Action http://taa.io/df14/app2/
  • 37. Time To Code! Sample App 2 http://taa.io/df14/app2/
  • 38. Time To Code! Sample App 3 Let’s build something…A Babel Fish* * Thanks Douglas Adams
  • 39. Time To Code! Let’s build something…A Babel Fish Three parts to the Babel Fish chatter app - Publisher - Text Input - Feed Item - Dynamic translation - Integration with 3rd party api - Google Translate API * bonus: VisualForce integration with a Canvas App
  • 40. Time To Code! Sample App 3 (A Babel Fish) See it in Action
  • 41. Time To Code! Sample App 3 (A Babel Fish) Words into the babel fish Auto Translated into native language
  • 42. Sample App 3 (A Babel Fish on a Visual Force Page) Time To Code! Subject of the Case Auto Translated into native language
  • 43. Sample App 3 (A Babel Fish) Want an installable AppExchange version? http://taa.io/df14/translator/ Time To Code!
  • 44. Time To Code! Sample App 4 Let’s build something…Voice Memo (Chrome and Firefox only)
  • 45. Time To Code! Let’s build something…Voice Memos Three parts to the VoiceMemo chatter app - Publisher - HTML5 Audio Input - Feed Item - Audio Playback - Integration with 3rd party persistence layer (S3) - CDN playback
  • 46. Time To Code! Sample App 4 (Voice Memo) See it in Action
  • 47. Time To Code! Sample App 4 (Voice Memo) Record the Voice memo with HTML5 only (Chrome/Firefox only) Audio Playback in the feed
  • 48. Sample App 4 (Voice Memo) Want an installable AppExchange version?* *? http://taa.io/df14/voicememo/ *No commercial support Time To Code!
  • 49. Rodney White Rodney White @rodney_white rodney@taa.io Want the framework? http://taa.io/df14/