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 5.1:
From Homestead to the Cloud
https://joind.in/14758
Joe Ferguson
Who Am I?
Joe Ferguson
PHP Developer
Twitter: @JoePFerguson
Organizer of @MemphisPHP
@NomadPHP Lightning Talks
Passionate ...
Laravel 5.1
What’s New?
PHP 5.5.9+
Laravel 5.1 will receive bug fixes for
2 years and security fixes for 3 years
PSR-2
Event Broadcasting
Middleware Parameters
Testing Overhaul
Encryption
How to get from
Homestead to the Cloud
Step One: Hello World
Create our project
Via Laravel Installer: laravel new hello-world
Via Composer:
composer create-project laravel/laravel he...
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
well, they used to be…
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?
Laravel Homestead
“Laravel Homestead is an official, pre-packaged
Vagrant "box" that provides you a wonderful
development e...
But I need…
What’s in the box:
• Ubuntu 14.04
• PHP 5.6
• HHVM
• Nginx
• MySQL
• Postgres
• Redis
• NodeJS
• Bower
• Grunt
• Gulp
• Be...
Getting Homestead
Install the box:
vagrant box add laravel/homestead
Clone the Repository:
git clone https://github.com/la...
Configure Homestead
Default: Hello World:
Update /etc/hosts
192.168.10.10 hello-world.app
Ready to vagrant up
Our code will be shared from our host machine
And mapped to the vagrant machine
~/PhpstormProjects/hel...
How I use Homestead
Install Homestead
http://laravel.com/docs/5.1/homestead#per-project-installation
$ vagrant up
Why do I prefer per-project?
Sharing your Homestead
environment
Do not version control:
Homestead.yml
DO version control:
Vagrantfile
after.sh
aliases
y...
What now?
How to access
hello-world.app
These are ports forwarded to homestead
Connect to the Database
Connect via a browser
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 reinstal...
Staking your own
Homestead
I like to customize homestead
AND
make sure I can easily update from upstream
Fork Homestead
Update your Homestead
Use after.sh for extras
./vendor/bin/homestead make —after
What could after.sh do?
You may not need after.sh
It is important to have a way to easily
reproduce your development environment
so that those one...
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,
• ...
Codeception.com
Acceptance Testing
Functional Testing
Unit Testing
• Our methods work
• Our product works
• Our product wo...
PhantomJS
PhantomJS is a headless WebKit scriptable
with a JavaScript API. It has fast
and native support for various
web ...
Codeception + PhantomJS
Basic Acceptance Test
Automate our Testing
Travis-CI
• Great for OSS projects (And free!)
• Easy to set up
• Easily test multiple versions of PHP
• Hosted on Travis ...
.travis.yml
Jenkins CI
• Easy To Install
• Easy Configuration
• Multiple Languages
• Probably Overkill for PHP
• Hosted on your servers
TeamCity
• Easy To Install
• Easy Configuration
• Multiple Languages
• Nice middle ground
• Hosted on your servers
TeamCity
Build Config
Build Steps
Edit Build Step
Step Three:
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 co...
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
Laravel Forge
• Unlimited Servers.
• Unlimited Sites.
• Unlimited Deployments.
• Push To Deploy.
Laravel Forge Plus
• Shar...
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
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 after.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
Restarting Services
Edit PHP Configuration
Delete the server
Deleting a site
Envoyer.io
Zero Downtime
Deployments with
Envoyer.io
Envoyer
10 Projects - $10/month or $100/year
20 Projects - $20/month or $200/year
Envoyer Plus
Unlimited Projects - $50/mo...
Add a project
Adding a Server
Add the SSH key from
Envoyer
Test Connection Status
Envoyer now connected to our Forge Server
Project Path
Our first Deployment
Deployment Recap
Deploy when code is pushed
Free Video Series at
Laracasts
https://laracasts.com/series/envoyer
https://envoyer.io/docs
Recap
Local Development: Use Homestead
Remote Deployment: Use Forge and Envoyer
Automate built tests and configure
Continuo...
Feedback!
https://joind.in/14758
Joe Ferguson
Twitter: @JoePFerguson
Email: joe@joeferguson.me
Freenode: joepferguson
Cont...
Upcoming SlideShare
Loading in …5
×

php[world] 2015 Laravel 5.1: From Homestead to the Cloud

1,111 views

Published on

With the recent release of Laravel Forge, Envoyer, and Homestead, it has never been easier to go from nothing to something with an easy-to-use PHP framework. This talk will cover creating a basic Laravel application using the Laravel-specific Vagrant box Homestead, connecting to a server (Linode, Rackspace, Digital Ocean), and deploying the application via Forge. The talk will also cover tips and tricks on customizing Homestead to fit your custom needs, as well as how to use Forge & Envoyer to deploy new versions of our application.

Published in: Technology

php[world] 2015 Laravel 5.1: From Homestead to the Cloud

  1. 1. Laravel 5.1: From Homestead to the Cloud https://joind.in/14758 Joe Ferguson
  2. 2. Who Am I? Joe Ferguson PHP Developer Twitter: @JoePFerguson Organizer of @MemphisPHP @NomadPHP Lightning Talks Passionate about Community
  3. 3. Laravel 5.1 What’s New?
  4. 4. PHP 5.5.9+
  5. 5. Laravel 5.1 will receive bug fixes for 2 years and security fixes for 3 years
  6. 6. PSR-2
  7. 7. Event Broadcasting
  8. 8. Middleware Parameters
  9. 9. Testing Overhaul
  10. 10. Encryption
  11. 11. How to get from Homestead to the Cloud
  12. 12. Step One: Hello World
  13. 13. Create our project Via Laravel Installer: laravel new hello-world Via Composer: composer create-project laravel/laravel hello-world --prefer-dist
  14. 14. Where should our project live? I prefer to keep things in ~/PhpstormProjects
  15. 15. MAMP, LAMP, WAMP, WAT? Mac/Linux/Windows Apache MySQL PHP These are all great tools
  16. 16. Is your server running MAMP?
  17. 17. Why not develop ON the server?
  18. 18. Do not develop ON the server
  19. 19. Develop in the same environment
  20. 20. Servers are expensive well, they used to be…
  21. 21. Virtual Machines are cheap
  22. 22. Our Use Case: Duplicate our server environment in a local virtual machine
  23. 23. Installing an OS takes time
  24. 24. Vagrant!
  25. 25. Vagrant allows you to: • Create a server • Configure a server • Delete a server …over and over and over..
  26. 26. Which Vagrant?
  27. 27. Laravel 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.”
  28. 28. But I need…
  29. 29. 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!
  30. 30. Getting Homestead Install the box: vagrant box add laravel/homestead Clone the Repository: git clone https://github.com/laravel/homestead.git Homestead
  31. 31. Configure Homestead Default: Hello World:
  32. 32. Update /etc/hosts 192.168.10.10 hello-world.app
  33. 33. Ready to vagrant up Our code will be shared from our host machine And mapped to the vagrant machine ~/PhpstormProjects/hello-world /home/vagrant/hello-world
  34. 34. How I use Homestead
  35. 35. Install Homestead http://laravel.com/docs/5.1/homestead#per-project-installation
  36. 36. $ vagrant up
  37. 37. Why do I prefer per-project?
  38. 38. Sharing your Homestead environment Do not version control: Homestead.yml DO version control: Vagrantfile after.sh aliases you should instruct potential collaborators to run the make command for themselves
  39. 39. What now?
  40. 40. How to access hello-world.app These are ports forwarded to homestead
  41. 41. Connect to the Database
  42. 42. Connect via a browser
  43. 43. Connect via SSH You could do this: But this is easier:
  44. 44. 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?
  45. 45. Staking your own Homestead I like to customize homestead AND make sure I can easily update from upstream
  46. 46. Fork Homestead
  47. 47. Update your Homestead
  48. 48. Use after.sh for extras ./vendor/bin/homestead make —after
  49. 49. What could after.sh do?
  50. 50. You may not need after.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
  51. 51. Step ??? Go make something great
  52. 52. Tests! You've written tests all along for your app right?
  53. 53. PHPUnit isn’t the only option! • Behat • phpspec • Codeception
  54. 54. Codeception • Selenium WebDriver integration • Elements matched by name, CSS, XPath • Symfony2, Laravel4, Yii, Phalcon, • Zend Framework integration • 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
  55. 55. Codeception.com Acceptance Testing Functional Testing Unit Testing • Our methods work • Our product works • Our product works as intended
  56. 56. PhantomJS PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.
  57. 57. Codeception + PhantomJS
  58. 58. Basic Acceptance Test
  59. 59. Automate our Testing
  60. 60. Travis-CI • Great for OSS projects (And free!) • Easy to set up • Easily test multiple versions of PHP • Hosted on Travis Servers
  61. 61. .travis.yml
  62. 62. Jenkins CI • Easy To Install • Easy Configuration • Multiple Languages • Probably Overkill for PHP • Hosted on your servers
  63. 63. TeamCity • Easy To Install • Easy Configuration • Multiple Languages • Nice middle ground • Hosted on your servers
  64. 64. TeamCity
  65. 65. Build Config
  66. 66. Build Steps
  67. 67. Edit Build Step
  68. 68. Step Three: Hello Production
  69. 69. Traditional Deployment
  70. 70. Better Deployment
  71. 71. But you still have to… • Update Dependencies • Run migrations • Update Assets
  72. 72. Continuous Delivery Production can be updated anytime
  73. 73. Continuous Delivery VS Continuous Deployment
  74. 74. 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
  75. 75. Laravel Forge “A simple way to deploy your laravel applications onto blazing fast servers”
  76. 76. Forge is Homestead and more in the cloud
  77. 77. Forge is not a server host
  78. 78. Forge uses your servers
  79. 79. Forge uses any* server *Any Internet accesible Ubuntu 14.04 x64 Server
  80. 80. Laravel Forge • Unlimited Servers. • Unlimited Sites. • Unlimited Deployments. • Push To Deploy. Laravel Forge Plus • Share Servers With Teammates. • Unlimited Servers. • Unlimited Sites. • Unlimited Deployments. • Push To Deploy. $10/Month $100/Year $20/Month $140/Year
  81. 81. Adding Servers To Forge
  82. 82. Adding a site to a server
  83. 83. Adding a ssh key to a server
  84. 84. Adding scheduled (cron) jobs
  85. 85. Adding daemons (supervisor)
  86. 86. Creating server networks
  87. 87. Server Monitoring
  88. 88. Update Server Meta Data
  89. 89. Adding our hello-world site
  90. 90. Install our Git Repository
  91. 91. Configure App Deployment
  92. 92. Deploy!
  93. 93. Deploy! Continuous Delivery!
  94. 94. Deployment Log
  95. 95. Setting Environment Variables
  96. 96. Queue Workers
  97. 97. Configure / Install SSL
  98. 98. Enable Quick Deploy
  99. 99. Quick Deploy Branch
  100. 100. Quick Deploy Branch Continuous Deployment!
  101. 101. Recipes Recipes a bash scripts that can be run on any of your Forge servers.
  102. 102. Cooking up Recipes Think of recipes like our after.sh in Homestead
  103. 103. All the things!
  104. 104. Not All The Things Some things we were doing in customize.sh we can do via Forge: • Queue Workers • Cron Jobs
  105. 105. Create Recipe
  106. 106. Run Install Bower Recipe
  107. 107. Forge Emails You Recipe Report
  108. 108. HipChat Notifications
  109. 109. Slack Notifications
  110. 110. Restarting Services Edit PHP Configuration
  111. 111. Delete the server
  112. 112. Deleting a site
  113. 113. Envoyer.io
  114. 114. Zero Downtime Deployments with Envoyer.io
  115. 115. Envoyer 10 Projects - $10/month or $100/year 20 Projects - $20/month or $200/year Envoyer Plus Unlimited Projects - $50/month or $500/year Envoyer Premium
  116. 116. Add a project
  117. 117. Adding a Server
  118. 118. Add the SSH key from Envoyer
  119. 119. Test Connection Status Envoyer now connected to our Forge Server
  120. 120. Project Path
  121. 121. Our first Deployment
  122. 122. Deployment Recap
  123. 123. Deploy when code is pushed
  124. 124. Free Video Series at Laracasts https://laracasts.com/series/envoyer https://envoyer.io/docs
  125. 125. Recap Local Development: Use Homestead Remote Deployment: Use Forge and Envoyer Automate built tests and configure Continuous Deployment Practice Continuous Delivery if not Continuous Deployment
  126. 126. Feedback! https://joind.in/14758 Joe Ferguson Twitter: @JoePFerguson Email: joe@joeferguson.me Freenode: joepferguson Contact Info:

×