際際滷

際際滷Share a Scribd company logo
Laravel 5
Brian Feaver
Lead Developer @ WiseBanyan
About Me
 Lead Developer at WiseBanyan
 Free online financial advisor
 http://wisebanyan.com
 10+ years of software development
Assumptions
You know these right?
 Composer
 Basic development environment
 Can read documentation
 http://laravel.com/docs/5.0#install-laravel
What am I covering?
 What is Laravel?
 Basics of Laravel (basics of any framework
ever?)
 Some cool stuff about Laravel (packaged libraries
and services)
 Some things not-so-cool
What is Laravel?
 PHP Framework for Web Artisans
 Built on top of Symfony2 Components
 Like any framework, provides services and
libraries to make interacting with web requests
and other services
The Basics
 Routing
 Controllers
 Templating (Blade)
 ORM (Eloquent)
Routing
 Routes are defined in routes.php
 Basic route uses a closure
 Or you can use a Controller
http://laravel.com/docs/5.0/routing
Routing w/ Closure
Routing with a Controller
Routing with a Controller
Route Parameters
You can define parameters within the route
Templates
Laravel uses the Blade template engine
Layouts
http://laravel.com/docs/5.0/templates
Templates
Using the layout
Eloquent (ORM)
http://laravel.com/docs/5.0/eloquent
Eloquent (ORM)
 Active Record
 Table - plural, snake_case class name
 Migrations
 Support relationships
 Soft deleting
 Timestamps
Eloquent (ORM)
The Bad
 Joins
 Uses subqueries
 You can do actual joins, but you have to write them using
the query builder yourself
 Can cause missing information with duplicate columns
 Eager loading - Model::with(relation)
 Runs two queries
 My usual Active Record gripes
The Cool Stuff
 Artisan
 Dependency Injection (Container)
 Queue
 Middleware
 Filesystem (Storage Facade)
 Encryption
 Authentication
The Cool Stuff
That really shouldnt be so cool
The Cool Stuff
That really shouldnt be so cool
Facades
Facades
What do they look like?
Facade::doSomethingCool()
Facades
What do they look like?
Facade::doSomethingCool()
Isnt that a static method?
Well, no
Facades
What are they?
 A static access to underlying service
 Look like static resources, but actually uses
services underneath
 Can be mocked for testing (at least with
Mockery no comment)
Facades
Why you shouldnt use them
 They hide the dependencies of the service or
class using them - This is the important one!
 Can be overridden, but then you override them
everywhere
http://programmingarehard.com/2014/01/11/stop-using-facades.html
Facades
What to do instead
You can instead inject them by their
underlying service class names.
See:
http://laravel.com/docs/5.0/facades#facade-class-reference
Facade Injection
Onto the cool 壊岳顎韓韓
Artisan
http://laravel.com/docs/5.0/artisan
Dependency Injection
(Container)
 App::make() - Facade
 Uses reflection to determine dependencies
 Does not require any configuration
 Can be configured with a ServiceProvider (PHP
class)
Queue
 Interface to:
 Amazon SQS
 IronMQ
 Redis queues
 Beanstalkd
 sync - calls job inline
http://laravel.com/docs/5.0/queues
Queue (worker)
 Use artisan to consume the job in the queue
 php artisan queue:work
 Also provides queue:listen and --daemon for
continuous workers
Middleware
 Allows processing or filtering of requests entering
the system
 http://laravel.com/docs/5.0/middleware
Encryption
 Simplified encryption using mcrypt
 http://laravel.com/docs/5.0/encryption
Filesystem
 Abstraction layer to local and remote filesystems
 Amazon S3
 FTP/SFTP
 Local
 Dropbox
 Uses the league/flysystem library
http://laravel.com/docs/5.0/filesystem
Authentication
 Includes libraries to do basic username/password
authentication out of the box
 Includes password recovery (Forgot password?)
 Protecting routes using filters
http://laravel.com/docs/5.0/authentication
Lots of additional
functionality
http://laravel.com/docs/5.0
Questions?

More Related Content

Laravel 5