www.it-ebooks.info ffirs.indd iffirs.indd i 1/10/2013 1:46:29 PM1/10/2013 1:46:29 PM www.it-ebooks.info PROFESSIONAL HEROKU® PROGRAMMING INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv PART I AN OVERVIEW OF HEROKU CHAPTER 1 How Heroku Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 CHAPTER 2 Architectural Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 CHAPTER 3 Porting Your Applications to Heroku . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 PART II CREATING AND MANAGING HEROKU APPLICATIONS CHAPTER 4 Deploying Your Applications to Heroku . . . . . . . . . . . . . . . . . . . . . . . . . . 73 CHAPTER 5 Managing Releases with Heroku . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 CHAPTER 6 Working with Add-Ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 CHAPTER 7 Managing, Monitoring, and Scaling Your Heroku Applications . . . . . . 133 PART III USING A DATA STORE WITH YOUR HEROKU APPLICATIONS CHAPTER 8 Using Heroku Postgres as a Data Store for Your Heroku Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 CHAPTER 9 Using Database.com as a Data Store for Your Heroku Applications . .181 CHAPTER 10 Using Third-Party Data Stores for Your Heroku Applications . . . . . . . 207 PART IV PROGRAMMING ON HEROKU’S POLYGLOT PLATFORM CHAPTER 11 Developing with Ruby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 CHAPTER 12 Developing with Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 CHAPTER 13 Developing with Other Supported Languages . . . . . . . . . . . . . . . . . . . . 301 CHAPTER 14 Understanding Buildpacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 PART V CREATING A NEW GENERATION OF HEROKU APPLICATIONS CHAPTER 15 Building Mobile Applications with Heroku . . . . . . . . . . . . . . . . . . . . . . . 383 CHAPTER 16 Building Social Applications with Heroku . . . . . . . . . . . . . . . . . . . . . . . . . 411 APPENDIX Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 ffirs.indd iffirs.indd i 1/10/2013 1:46:29 PM1/10/2013 1:46:29 PM www.it-ebooks.info ffirs.indd iiffirs.indd ii 1/10/2013 1:46:30 PM1/10/2013 1:46:30 PM www.it-ebooks.info PROFESSIONAL Heroku ® Programming ffirs.indd iiiffirs.indd iii 1/10/2013 1:46:30 PM1/10/2013 1:46:30 PM www.it-ebooks.info ffirs.indd ivffirs.indd iv 1/10/2013 1:46:30 PM1/10/2013 1:46:30 PM www.it-ebooks.info PROFESSIONAL Heroku ® Programming Chris Kemp Brad Gyger John Wiley & Sons, Ltd. ffirs.indd vffirs.indd v 1/10/2013 1:46:30 PM1/10/2013 1:46:30 PM www.it-ebooks.info © 2013 John Wiley & Sons, Ltd. Registered of ce John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom For details of our global editorial of ces, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com. The right of the author to be identi ed as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and speci cally disclaim all warranties, including without limitation warranties of tness for a particular purpose. No warranty may be created or extended by sales or pro- motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the pub- lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its af liates, in the United States and other countries, and may not be used without written permission. Heroku is a registered trademark of Salesforce.com, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in this book. Heroku product screenshots courtesy of Heroku, Inc. A catalogue record for this book is available from the British Library. 978-1-118-50899-2 (paperback) 978-1-118-50901-2 (ebook) 978-1-118-50902-9 (ebook) 978-1-118-50903-6 (ebook) Set in 9.5 /12 Sabon LT Std Roman, by MPS Limited, Chennai Printed in the United States by Bind-Rite ffirs.indd viffirs.indd vi 1/10/2013 1:46:31 PM1/10/2013 1:46:31 PM www.it-ebooks.info To my ancée, Fiona, whose support and inspiration made writing this book possible; and my parents, Don and Vlasta, who gave me the opportunities throughout my life that made this and all of my achievements possible. —C To my wife, Nabila; my son, Cameron; and my parents, Roger and Judy. Without you all this wouldn’t have been possible. —B ffirs.indd viiffirs.indd vii 1/10/2013 1:46:31 PM1/10/2013 1:46:31 PM www.it-ebooks.info ffirs.indd viiiffirs.indd viii 1/10/2013 1:46:31 PM1/10/2013 1:46:31 PM www.it-ebooks.info [...]... Heroku Dev Center Professional Heroku Programming s GitHub Repository Log a Ticket with Heroku Support Heroku Ninja Heroku Java Stack Overflow Heroku Community Google Group Heroku IRC Channel Heroku s Twitter Accounts Heroku s Official Blog Heroku News Heroku on Facebook Heroku Status Heroku Postgres Heroku Add-Ons Heroku Add-On Provider Site Database.com User Guide Developer Force Integration Force.com... APPLICATIONS WITH HEROKU 411 Writing Facebook Applications with PHP 412 Creating a Facebook Canvas Application Writing the Contest App Code Deploying the Application to Heroku 412 416 424 Making Heroku Applications Social with the Chatter API Creating a Shadow Object in Database.com Summary 429 430 444 APPENDIX: ADDITIONAL RESOURCES 445 The Heroku Website The Heroku Dev Center Professional Heroku Programming s... 447 448 449 450 451 451 452 453 454 455 455 456 457 458 459 460 461 xxii www.it-ebooks.info ftoc.indd xxii 1/10/2013 1:48:58 PM CONTENTS Heroku s Github Site Heroku API Documentation Heroku Partners Heroku Beta Program Sign-Up Heroku Success Stories Heroku on Vimeo Heroku Waza The Twelve-Factor App James Ward’s Blog INDEX 461 462 463 464 464 465 466 467 468 469 xxiii www.it-ebooks.info ftoc.indd xxiii... Existing Applications Summary 63 65 66 66 67 68 PART II: CREATING AND MANAGING HEROKU APPLICATIONS CHAPTER 4: DEPLOYING YOUR APPLICATIONS TO HEROKU Installing the Heroku Toolbelt Git Foreman The Heroku Client 73 73 74 75 76 Interacting with Heroku via the Command-Line Interface The Magic of git push Post Deploy Hooks Navigating the Heroku Dashboard 77 79 80 80 Changing Your Application’s Name Adding Custom... and deploying apps is Heroku Now part of the Salesforce.com family of companies, Heroku is considered by many to be the leading PaaS for multi-language, cloud-based app deployment With more than a million users, and more than two-and-a-half million deployed apps, Heroku also supports more languages and third-party tools than any other PaaS in the market today Professional Heroku Programming is a hands-on... Chapter 3, “Porting Your Applications to Heroku, ” outlines the tasks and considerations when deciding to port apps to Heroku Part II, “Creating and Managing Heroku Applications,” provides the fundamentals of daily life with Heroku After reading this Part, you should be able to grasp any aspect of managing your apps on Heroku ➤ ➤ Chapter 5, “Managing Releases with Heroku, ” describes how you can manage... needs ➤ ➤ Chapter 8, “Using Heroku Postgres as a Data Store for Your Heroku Applications,” details the most commonly used data store option, Heroku Postgres While delivered by the same company, Heroku Postgres is its own unique data-as-a-service (DaaS) that can be consumed either with a Heroku app or as a standalone product Chapter 10, “Using Third-Party Data Stores for Your Heroku Applications,” switches... not strictly required in most cases On your local machine, you’ll need to have created a Heroku user account and have the Heroku Toolbelt installed on your machine You can create your Heroku account at any time by visiting https://api .heroku. com/signup You can download the Heroku Toolbelt from https://toolbelt .heroku. com You will also need to have your local machine configured for development in your... www.wrox.com/dynamic/books/download aspx to see the code available for this book and all other Wrox books There is also a GitHub repository available at https://github.com/ ProfessionalHerokuProgramming where code can be downloaded locally using: $ git clone git@github.com:ProfessionalHerokuProgramming /ch-.git where is the number of the chapter that the code appears in, and . CREATING AND MANAGING HEROKU APPLICATIONS CHAPTER 4: DEPLOYING YOUR APPLICATIONS TO HEROKU 73 Installing the Heroku Toolbelt 73 Git 74 Foreman 75 The Heroku Client 76 Interacting with Heroku via the. as a Data Store for Your Heroku Applications . .181 CHAPTER 10 Using Third-Party Data Stores for Your Heroku Applications . . . . . . . 207 PART IV PROGRAMMING ON HEROKU S POLYGLOT PLATFORM CHAPTER. Monitoring, and Scaling Your Heroku Applications . . . . . . 133 PART III USING A DATA STORE WITH YOUR HEROKU APPLICATIONS CHAPTER 8 Using Heroku Postgres as a Data Store for Your Heroku Applications