all the laravel things – up & running to making $$
Post on 22-Jan-2017
78 Views
Preview:
TRANSCRIPT
20162016
All the Laravel things: up and running to making $$
Joe Ferguson
Who Am I?Joe Ferguson
PHP Developer
Engineer @ Aol.
Twitter: @JoePFerguson
Organizer of @MemphisPHP
OSMI Board Member
@NomadPHP Lightning Talks
Passionate about Community
For Further Reading
laravelupandrunning.com easylaravelbook.com
What exactly is Laravel?
Laravel EcosystemFrameworkTools Learning &
Community
Quick note on versions
5.1 LTS bug fixes for 2 years, security fixes for 3 years
Non LTS: bug fixes for 6 months, security fixes for 1 year
5.1 is currently the only LTS version
Which version should you use?
5.3 for my own projects
5.1 for client projects
Getting Laravel
composer global require “laravel/installer”
Installing Laravel
laravel new quickstart-basic-5.3
Install via Composer
composer create-project --prefer-dist laravel/laravel blog
Local Dev Environment
What’s in Homestead
• Ubuntu 16.04• PHP 7.0• HHVM• Nginx• MySQL• MariaDB• Sqlite3• Postgres
• Composer• NodeJS• Bower• Grunt• Gulp• Beanstalkd• Memcached• Redis
Getting Homestead
git clone https://github.com/laravel/homestead.git Homestead
Getting Homestead
cd Homestead && bash init.sh
How I use Homestead
composer require —dev laravel/homestead
Make Homestead
./vendor/bin/homested make —aliases
What is —aliases?
Configuring Homestead
Starting Homestead
Inspecting Homestead
Edit /etc/hosts
Optional for per project Homestead
Inspecting Homestead
Inspecting Homestead
Stopping Homestead
Don’t version control Homestead.yaml
Questions?
Getting Started with Laravel
Project Structure
app Folder
config Folder
database Folder
public Folder
resources Folder
routes Folder
Model Factories
database/factories/ModelFactory.php
User Migration up()
database/migrations
User Migration down()
database/migrations
Database Seeders
Artisan Commands
Artisan Commands
Create Migration
artisan make:migration create_widgets_table
Create Migration
Create Migration
Run Migration(s)
artisan migrate
Inspect the Database
Password is “secret”
Inspect the Database
Create a model
artisan make:model Widget
Widget model
Add Widget ModelFactory
database/factories/ModelFactory.php
Create a seeder
artisan make:seeder WidgetSeeder
WidgetSeeder
DatabaseSeeder
Run Database Seeders
artisan db:seed
Users Table
Widgets Table
Routing
routes/web.php
Why 3 route files?!
Add /widgets Route
localhost:8000/widgets
Frontend Development
Run: npm install
Run: gulp
Compiled Assets
Layouts
Example View
Return a view()
routes/web.php
Refresh /widgets
localhost:8000/widgets
Clean up our layout
Widgets Index View
Pass data to a view
routes/web.php
localhost:8000/widgets
Questions?
Testing our Application
Testing our Widgets
Testing our Widgets
Testing our Widgets
Running phpunit
Route Groups
Form Requests
WidgetCreateRequest
HTML Forms
Widget Routes
Add Widget
Test Add Widget Form
Questions?
Controllers
Routing to Controllers
Routing to Controllers
Routing to Controllers
Widget Tests Still Pass
Questions?
Model Relationships
One to One
A User has a Phone Number
One to Many
A Post has many Comments
Many to Many
Users have may Roles
Task belongs to User
User has many Tasks
Query Model Relationships
The N+1 Problem
Eager Loading
Questions?
How do we get it to the server?
Envoy
Envoy provides easy ways to run command commands on remote servers such as pulling code from git, running artisan commands, etc.
Envoy uses blade template syntax
Envoy only supports Mac & Linux
Sample Envoy Config
Sample Envoy Config
Envoy Configuration
Easy OAuth Login
Laravel Socialite
Easily allow users to authenticate via Github, Google, Twitter, Facebook, Bitbucket, or Linkedin
Handles almost all the boilerplate for you
https://github.com/laravel/socialite
composer require laravel/socialite
Configure Socialite
Configure Socialite
AuthController
Add Socialite Routes
Making $$$
Laravel Cashier
Expressive interface to Stripe and Braintree subscription billing services
Free, open source package easily added to Laravel
Designed for subscription, not one off charges
https://laravel.com/docs/5.3/billing
Installing Cashier
Configure Cashier
Cashier Migration
Billable Trait
Stripe API Keys
Subscribing a User
https://laravel.com/docs/5.3/billing
Laravel Spark
SASS in a box
You bring the Service
Spark brings the boilerplate of billing, authentication, and more
$99 For a single site
$299 For unlimited sites
Laravel Spark
Questions?
Artisan Commands
Create a new Command
Create a new Command
app/Console/Kernel.php
BasicCommand.php
Signature
Description
Constructor
Handle The Command
Running our Command
Output Some Text
Output Some Text
Output Warning Text
Output Warning Text
Output Error Text
Output Error Text
Questions?
Authentication
artisan make:auth
View Files
Auth Routes
Layout :(
Register a new user
Logged In User
Add our Navigation
http://localhost:8000
localhost:8000/widgets
Multiple Middleware
Not Logged In?
Test Errors and Failure
Run test as a user
Test now passes
Questions?
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• Share Servers With Teammates.• Unlimited Servers.• Unlimited Sites.• Unlimited Deployments.• Push To Deploy.
$15/Month$140/Year
$30/Month$300/Year
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
LetsEncrypt.org100% Supported
Envoyer.io
Zero Downtime Deployments with
Envoyer.io
Envoyer10 Projects - $10/month or $100/year
20 Projects - $20/month or $200/year
Envoyer Plus
Unlimited Projects - $50/month or $500/year
Envoyer Premium
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
Questions?
Feedback!https://joind.in/talk/4eb90
Joe FergusonTwitter: @JoePFergusonEmail: joe@joeferguson.meFreenode: joepferguson
Contact Info:
top related