Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Laravel Forge: 
From Hello World to Hello Production
Step One: Hello World 
Step Two: CI, CD, OMG 
Step Three: ???? 
Step Four: Hello 
Production
Step One: Hello World
Create our project 
Via Laravel Installer: laravel new hello-world 
Via Composer: 
composer create-project laravel/laravel...
Where should our project 
live? 
I prefer to keep things in ~/PhpstormProjects
MAMP, LAMP, WAMP, 
WAT? 
Mac/Linux/Windows Apache MySQL PHP 
These are all great tools
Is your server running 
MAMP?
Why not develop ON 
the server?
Do not develop ON 
the server
Develop in the same 
environment
Servers are expensive
Virtual Machines are 
cheap
Our Use Case: 
Duplicate our server environment 
in a local virtual machine
Installing an OS takes time
Vagrant!
Vagrant allows you to: 
• Create a server 
• Configure a server 
• Delete a server 
…over and over and over..
Which Vagrant?
Homestead 
“Laravel Homestead is an official, pre-packaged 
Vagrant "box" that provides you a wonderful 
development envir...
But I need…
What’s in the box: 
• Ubuntu 14.04 
• PHP 5.6 
• HHVM 
• Nginx 
• MySQL 
• Postgres 
• Redis 
• NodeJS 
• Bower 
• Grunt 
...
Getting Homestead 
Install the box: 
vagrant box add laravel/homestead 
Clone the Repository: 
git clone https://github.co...
Configure Homestead 
Default: Hello World:
Update /etc/hosts* 
192.168.10.10 hello-world.app 
*This step is optional
Ready to vagrant up 
Our code will be shared from our host machine 
~/PhpstormProjects/hello-world 
And mapped to the vagr...
$ vagrant up
What now?
How to access our 
hello-world.app 
These are ports forwarded to homestead
Connect to the Database
Connect via a browser
Or use the hostname* 
*If you added the host to your /etc/hosts
Connect via SSH 
You could do this: 
But this is easier:
Homestead is awesome! 
We now have a local dev environment 
we can easily use, break, and restore 
without having to reins...
Staking your own 
Homestead 
I like to customize homestead 
AND 
make sure I can easily update from upstream
Fork Homestead
Update your Homestead
Add another provisioner
What could customize.sh do?
You may not need 
customize.sh 
It is important to have a way to easily 
reproduce your development environment 
so that t...
Step ??? 
Go make something great
Tests! 
You've written tests all along for your app right?
PHPUnit isn’t the only 
option! 
• Behat 
• phpspec 
• Codeception
Codeception 
• Selenium WebDriver integration 
• Elements matched by name, CSS, XPath 
• Symfony2, Laravel4, Yii, Phalcon,...
Basic Acceptance Test
Automate our Testing
TeamCity
Build Steps
All OK? Deploy!
Step Four: 
Hello Production
Traditional Deployment
Better Deployment
But you still have to… 
• Update Dependencies 
• Run migrations 
• Update Assets
Continuous Delivery 
Production can be updated anytime
Continuous Delivery 
VS 
Continuous Deployment
Continuous Deployment 
“Deploy my code every time tests pass” 
Continuous Delivery 
“We can deploy whenever we want…but we...
Laravel Forge 
“A simple way to deploy your laravel applications 
onto blazing fast servers”
Forge is Homestead 
and more in the cloud
Forge is not a server host
Forge uses your servers
Forge uses any* server 
*Any Internet accesible Ubuntu 14.04 x64 Server
Adding Servers To Forge
Adding a site to a server
Adding a ssh key to a 
server
Adding scheduled (cron) 
jobs
Adding daemons 
(supervisor)
Creating server networks
Server Monitoring
Update Server Meta Data
Adding our hello-world site
Forge can do more…
Add a WordPress Site
Ready to install
Removing WordPress 
Does NOT remove your WordPress Database!
Install Craft CMS
Craft CMS
Uninstall Craft CMS 
Does NOT remove your Craft CMS Database!
Install our Git Repository
Configure App Deployment
Deploy!
Deploy! 
Continuous 
Delivery!
Deployment Log
Setting Environment 
Variables
Queue Workers
Configure / Install SSL
Enable Quick Deploy
Quick Deploy Branch
Quick Deploy Branch 
Continuous 
Deployment!
Recipes 
Recipes a bash scripts that can be 
run on any of your Forge servers.
Cooking up Recipes 
Think of recipes like our customize.sh in Homestead
All the things!
Not All The Things 
Some things we were doing in customize.sh 
we can do via Forge: 
• Queue Workers 
• Cron Jobs
Create Recipe
Run Install Bower Recipe
Forge Emails You Recipe 
Report
HipChat Notifications
Slack Notifications 
You can use cURL to post to Slack channels 
curl -X POST --data-urlencode ‘payload= 
{"channel": “#de...
Edit our Deployment 
Script 
Now every deployment will run bower and 
notify our slack channel that our repo was deployed.
Hey Joe…
Been there, done that
Enable Slack
Add the Integration
Authenticate with Slack
Deploy!
Restarting Services 
Edit PHP Configuration
Delete the server
Deleting a site
Forge Circles* 
*Forge Plus Feature
Forge Circles* 
*Forge Plus Feature
Forge VS Forge Plus 
• Manage 5 Servers 
• Unlimited Servers 
• Forge Circles
Recap 
Local Development: Use Homestead 
Automate build tests and configure 
Continuous Deployment 
Practice Continuous De...
Feedback! 
https://joind.in/talk/view/11870 
Contact Info: 
Joe Ferguson 
Twitter: @Svpernova09 
Email: joe@joeferguson.me
Upcoming SlideShare
Loading in …5
×

Laravel Forge: Hello World to Hello Production

7,620 views

Published on

Slides for the talk I gave at the inaugural php[world] conference on November 12th 2014 in Washington, DC

Published in: Technology
  • Instead of Laravel forge for Laravel apps, I would recommend using Cloudways Laravel hosting (https://www.cloudways.com/en/laravel-hosting.php ) platform. If you are using Forge, you will have to first create account on the infrastructure then connect it with Forge, which means apart from the hassle of extra work you also have to deal with double invoice, one from forge and another from infrastructure provider. This is not the case in Cloudways platform.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Njce! Thanks for sharing.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Laravel Forge: Hello World to Hello Production

  1. 1. Laravel Forge: From Hello World to Hello Production
  2. 2. Step One: Hello World Step Two: CI, CD, OMG Step Three: ???? Step Four: Hello Production
  3. 3. Step One: Hello World
  4. 4. Create our project Via Laravel Installer: laravel new hello-world Via Composer: composer create-project laravel/laravel hello-world --prefer-dist
  5. 5. Where should our project live? I prefer to keep things in ~/PhpstormProjects
  6. 6. MAMP, LAMP, WAMP, WAT? Mac/Linux/Windows Apache MySQL PHP These are all great tools
  7. 7. Is your server running MAMP?
  8. 8. Why not develop ON the server?
  9. 9. Do not develop ON the server
  10. 10. Develop in the same environment
  11. 11. Servers are expensive
  12. 12. Virtual Machines are cheap
  13. 13. Our Use Case: Duplicate our server environment in a local virtual machine
  14. 14. Installing an OS takes time
  15. 15. Vagrant!
  16. 16. Vagrant allows you to: • Create a server • Configure a server • Delete a server …over and over and over..
  17. 17. Which Vagrant?
  18. 18. Homestead “Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.”
  19. 19. But I need…
  20. 20. What’s in the box: • Ubuntu 14.04 • PHP 5.6 • HHVM • Nginx • MySQL • Postgres • Redis • NodeJS • Bower • Grunt • Gulp • Beanstalkd • Memcached • Laravel Envoy Fabric + HipChat Extension + more!
  21. 21. Getting Homestead Install the box: vagrant box add laravel/homestead Clone the Repository: git clone https://github.com/laravel/homestead.git Homestead
  22. 22. Configure Homestead Default: Hello World:
  23. 23. Update /etc/hosts* 192.168.10.10 hello-world.app *This step is optional
  24. 24. Ready to vagrant up Our code will be shared from our host machine ~/PhpstormProjects/hello-world And mapped to the vagrant machine /home/vagrant/hello-world
  25. 25. $ vagrant up
  26. 26. What now?
  27. 27. How to access our hello-world.app These are ports forwarded to homestead
  28. 28. Connect to the Database
  29. 29. Connect via a browser
  30. 30. Or use the hostname* *If you added the host to your /etc/hosts
  31. 31. Connect via SSH You could do this: But this is easier:
  32. 32. Homestead is awesome! We now have a local dev environment we can easily use, break, and restore without having to reinstall the entire operating system and developer tools. Break something?
  33. 33. Staking your own Homestead I like to customize homestead AND make sure I can easily update from upstream
  34. 34. Fork Homestead
  35. 35. Update your Homestead
  36. 36. Add another provisioner
  37. 37. What could customize.sh do?
  38. 38. You may not need customize.sh It is important to have a way to easily reproduce your development environment so that those one off changes you make are documented and two months down the road you don’t destroy & up your environment to find out you have stuff missing
  39. 39. Step ??? Go make something great
  40. 40. Tests! You've written tests all along for your app right?
  41. 41. PHPUnit isn’t the only option! • Behat • phpspec • Codeception
  42. 42. Codeception • Selenium WebDriver integration • Elements matched by name, CSS, XPath • Symfony2, Laravel4, Yii, Phalcon, Zend Framework • PageObjects and StepObjects included • BDD-style readable tests • Powered by PHPUnit • API testing: REST,SOAP,XML-RPC • Facebook API testing • Data Cleanup • HTML, XML, TAP, JSON reports • CodeCoverage and Remote CodeCoverage • Parallel Execution
  43. 43. Basic Acceptance Test
  44. 44. Automate our Testing
  45. 45. TeamCity
  46. 46. Build Steps
  47. 47. All OK? Deploy!
  48. 48. Step Four: Hello Production
  49. 49. Traditional Deployment
  50. 50. Better Deployment
  51. 51. But you still have to… • Update Dependencies • Run migrations • Update Assets
  52. 52. Continuous Delivery Production can be updated anytime
  53. 53. Continuous Delivery VS Continuous Deployment
  54. 54. Continuous Deployment “Deploy my code every time tests pass” Continuous Delivery “We can deploy whenever we want…but we control when” Magnus Hedemark: http://puppetlabs.com/blog/continuous-delivery-vs-continuous-deployment-whats-diff
  55. 55. Laravel Forge “A simple way to deploy your laravel applications onto blazing fast servers”
  56. 56. Forge is Homestead and more in the cloud
  57. 57. Forge is not a server host
  58. 58. Forge uses your servers
  59. 59. Forge uses any* server *Any Internet accesible Ubuntu 14.04 x64 Server
  60. 60. Adding Servers To Forge
  61. 61. Adding a site to a server
  62. 62. Adding a ssh key to a server
  63. 63. Adding scheduled (cron) jobs
  64. 64. Adding daemons (supervisor)
  65. 65. Creating server networks
  66. 66. Server Monitoring
  67. 67. Update Server Meta Data
  68. 68. Adding our hello-world site
  69. 69. Forge can do more…
  70. 70. Add a WordPress Site
  71. 71. Ready to install
  72. 72. Removing WordPress Does NOT remove your WordPress Database!
  73. 73. Install Craft CMS
  74. 74. Craft CMS
  75. 75. Uninstall Craft CMS Does NOT remove your Craft CMS Database!
  76. 76. Install our Git Repository
  77. 77. Configure App Deployment
  78. 78. Deploy!
  79. 79. Deploy! Continuous Delivery!
  80. 80. Deployment Log
  81. 81. Setting Environment Variables
  82. 82. Queue Workers
  83. 83. Configure / Install SSL
  84. 84. Enable Quick Deploy
  85. 85. Quick Deploy Branch
  86. 86. Quick Deploy Branch Continuous Deployment!
  87. 87. Recipes Recipes a bash scripts that can be run on any of your Forge servers.
  88. 88. Cooking up Recipes Think of recipes like our customize.sh in Homestead
  89. 89. All the things!
  90. 90. Not All The Things Some things we were doing in customize.sh we can do via Forge: • Queue Workers • Cron Jobs
  91. 91. Create Recipe
  92. 92. Run Install Bower Recipe
  93. 93. Forge Emails You Recipe Report
  94. 94. HipChat Notifications
  95. 95. Slack Notifications You can use cURL to post to Slack channels curl -X POST --data-urlencode ‘payload= {"channel": “#devops", "username": "Forge", "text": “'"$Message"'", "icon_emoji": ":shipit:"}' https://<You>.slack.com/services/ hooks/incoming-webhook ?token=<Your-Slack-Token>
  96. 96. Edit our Deployment Script Now every deployment will run bower and notify our slack channel that our repo was deployed.
  97. 97. Hey Joe…
  98. 98. Been there, done that
  99. 99. Enable Slack
  100. 100. Add the Integration
  101. 101. Authenticate with Slack
  102. 102. Deploy!
  103. 103. Restarting Services Edit PHP Configuration
  104. 104. Delete the server
  105. 105. Deleting a site
  106. 106. Forge Circles* *Forge Plus Feature
  107. 107. Forge Circles* *Forge Plus Feature
  108. 108. Forge VS Forge Plus • Manage 5 Servers • Unlimited Servers • Forge Circles
  109. 109. Recap Local Development: Use Homestead Automate build tests and configure Continuous Deployment Practice Continuous Delivery if not Continuous Deployment Remote Deployment: Use Forge
  110. 110. Feedback! https://joind.in/talk/view/11870 Contact Info: Joe Ferguson Twitter: @Svpernova09 Email: joe@joeferguson.me

×