Laravel and Composer
-
Upload
phil-sturgeon -
Category
Documents
-
view
7.123 -
download
7
description
Transcript of Laravel and Composer
![Page 1: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/1.jpg)
Compose all the things@philsturgeon
Tuesday, 26 February 13
![Page 2: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/2.jpg)
Derp derpy derp!
Kapture
PyroCMS
CodeIgniter
FuelPHP
PancakeApp
PHP The Right Way
PHP Town Hall
PHP-FIG
I have a weird accent
@philsturgeon
Tuesday, 26 February 13
![Page 3: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/3.jpg)
“I could spend 10 minutes writing some code, but [stuff] that, I can just install a Gem.”
-- Elliott Kember, RiotHQ
Tuesday, 26 February 13
![Page 4: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/4.jpg)
Ruby Gems
Warden - Simple generic authentication
OmniAuth - Integrate Facebook, Twitter, etc
OAuth / OAuth 2 - Go-to gems for oauth
Thor or Clam - Command line frameworks
ActiveRecord - THE ORM for Ruby
Tuesday, 26 February 13
![Page 5: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/5.jpg)
Python (PIP)
Requests - THE HTTP class
PIL - Image Manipulation (but doesnt suck)
UJSON - UTF-8 support + way faster
Flask - RESTful micro-framework
PyYAML - Quick YAML parser
Tuesday, 26 February 13
![Page 6: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/6.jpg)
Tuesday, 26 February 13
![Page 7: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/7.jpg)
Tuesday, 26 February 13
![Page 8: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/8.jpg)
What about PHP?
Tuesday, 26 February 13
![Page 9: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/9.jpg)
Tuesday, 26 February 13
![Page 10: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/10.jpg)
Tuesday, 26 February 13
![Page 11: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/11.jpg)
Tuesday, 26 February 13
![Page 12: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/12.jpg)
sudo apt-get install php-pear php5-dev
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
Installing stuff with PEAR
Tuesday, 26 February 13
![Page 13: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/13.jpg)
Cool story bro
Tuesday, 26 February 13
![Page 14: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/14.jpg)
“Active Package”
Tuesday, 26 February 13
![Page 15: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/15.jpg)
“Modern Package”
Tuesday, 26 February 13
![Page 16: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/16.jpg)
Tuesday, 26 February 13
![Page 17: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/17.jpg)
Tuesday, 26 February 13
![Page 18: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/18.jpg)
Tuesday, 26 February 13
![Page 19: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/19.jpg)
Tuesday, 26 February 13
![Page 20: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/20.jpg)
The Dawn of Frameworks!
Tuesday, 26 February 13
![Page 21: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/21.jpg)
Tuesday, 26 February 13
![Page 22: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/22.jpg)
Tuesday, 26 February 13
![Page 23: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/23.jpg)
Tuesday, 26 February 13
![Page 24: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/24.jpg)
Write ALL THE CODE
DATABAZE!!
Benchmarking
Cache
Calender
Shopping Cart?
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniter
Tuesday, 26 February 13
![Page 25: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/25.jpg)
Tuesday, 26 February 13
![Page 26: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/26.jpg)
Tuesday, 26 February 13
![Page 27: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/27.jpg)
Write ALL THE CODE
Benchmarking
Cache
Calender
Cart
Driver
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniterKohanaORMHTTPUTF-8
TemplatesHMVC
Tuesday, 26 February 13
![Page 28: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/28.jpg)
Write ALL THE CODE
Benchmarking
Cache
Calender
Cart
Driver
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniter
FuelPHPREST
ScaffoldingMigrations
AuthMore Mongo
KohanaORMHTTPUTF-8
TemplatesHMVC
Tuesday, 26 February 13
![Page 29: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/29.jpg)
Write ALL THE CODE
Benchmarking
Cache
Calender
Cart
Driver
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniter
FuelPHPREST
ScaffoldingMigrations
AuthMore Mongo
Laravel 3Epic RoutesCALLBACKS
IoCBundles
KohanaORMHTTPUTF-8
TemplatesHMVC
Tuesday, 26 February 13
![Page 30: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/30.jpg)
FW Packages = Solution?
CodeIgniter: Sparks
FuelPHP: Cells
Laravel 3: Bundles
Tuesday, 26 February 13
![Page 31: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/31.jpg)
codeigniter-oauth2
fuel-oauth2
laravel-oauth2
Tuesday, 26 February 13
![Page 32: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/32.jpg)
Tuesday, 26 February 13
![Page 33: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/33.jpg)
Tuesday, 26 February 13
![Page 34: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/34.jpg)
Composer Setup
$ mkdir playground
$ cd playground
$ curl -s https://getcomposer.org/installer | php
$ ls
composer.phar
$ vim composer.json
Tuesday, 26 February 13
![Page 35: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/35.jpg)
Require Packages
{
"minimum-stability": "beta",
"require": {
"dflydev/markdown": "1.0.*",
"illuminate/database": "*"
}
}
Tuesday, 26 February 13
![Page 36: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/36.jpg)
Install those Packages
$ ./composer.phar install
Loading composer repositories with package information
Installing dependencies
- Installing dflydev/markdown (v1.0.2)
Downloading: 100%
....... and so on
Tuesday, 26 February 13
![Page 37: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/37.jpg)
Other Repos
{ "repositories": [ { "type": "vcs", "url": "http://github.com/mycompany/privaterepo" }, { "type": "vcs", "url": "http://svn.example.org/private/repo" }, { "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" } ], "require": { "company/package": "*", "company/package2": "*", "company/package3": "2.0.0" }}
Tuesday, 26 February 13
![Page 38: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/38.jpg)
Tuesday, 26 February 13
![Page 39: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/39.jpg)
Why not just use them?
Boilerplate makes kittens cry
Service Providers + Facade avoid boilerplate
IoC is SIMPLE + Controller integration
Lowest barrier to entry
Tuesday, 26 February 13
![Page 40: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/40.jpg)
Tuesday, 26 February 13
![Page 41: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/41.jpg)
Tuesday, 26 February 13
![Page 42: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/42.jpg)
Where is Laravel 4
https://github.com/laravel/laravel/tree/develop
https://github.com/illuminate
https://github.com/laravel/framework
Tuesday, 26 February 13
![Page 43: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/43.jpg)
Cloning Laravel 4
$ git clone git://github.com/laravel/laravel.git
-o laravel -b develop playground
Tuesday, 26 February 13
![Page 44: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/44.jpg)
Install Dependencies
$ cd playground
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar install
Tuesday, 26 February 13
![Page 45: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/45.jpg)
Building a Package
$ php artisan workbench
What is vendor name of the package?Epic
What is the package name?Unicorn
What is your name?Phil Sturgeon
What is your e-mail [email protected]
Tuesday, 26 February 13
![Page 46: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/46.jpg)
Understanding Structure
Tuesday, 26 February 13
![Page 47: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/47.jpg)
Workbench Structure
workbench epic unicorn .travis.yml composer.json phpunit.xml public src Epic Unicorn UnicornServiceProvider.php config lang migrations views tests
Tuesday, 26 February 13
![Page 48: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/48.jpg)
Metadata{
"name": "epic/unicorn", "authors": [ { "name": "Phil Sturgeon", "email": "[email protected]" } ], "require": { "php": ">=5.3.0", "illuminate/support": "4.0.x" }, "autoload": { "classmap": [ "src/migrations" ], "psr-0": { "Epic\\Unicorn": "src/" } }, "minimum-stability": "dev"}
Tuesday, 26 February 13
![Page 49: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/49.jpg)
Unit-tests
phpunit.de
travis-ci.org
Tuesday, 26 February 13
![Page 50: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/50.jpg)
.travis.yml
language: php
php: - 5.3 - 5.4
before_script: - curl -s http://getcomposer.org/installer | php - php composer.phar install --dev
script: phpunit
Tuesday, 26 February 13
![Page 51: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/51.jpg)
PSR-WAT?PHP Standard Recommendation
PHP-FIG: Framework Interoperability Group
Website: php-fig.org
Drupal, Joomla, phpBB, Symfony2, PyroCMS, FLOW, Lithium, Zend Framework, AWS SDK, CakePHP, Doctrine, PEAR, Propel, Zikula, others...
Hopefully Laravel soon.
Tuesday, 26 February 13
![Page 52: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/52.jpg)
PSR-0Autoloading Standard
\<Vendor Name>\(<Namespace>\)*<Class Name>
Classes Session_Cache is Session/Cache.php
Must have a top-level namespace
http://bit.ly/PSR-0
Tuesday, 26 February 13
![Page 53: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/53.jpg)
PSR-1Basic Coding Standard
Files are UTF-8
Definition OR side-effect
Constants are upper-case
Class names are StudlyCaps
Method names camelCase()
http://bit.ly/PSR-one
Tuesday, 26 February 13
![Page 54: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/54.jpg)
PSR-2Coding Style Guide
SHOULD limit to 80 or 120 characters per line
All PHP files MUST use the Unix LF (linefeed) line ending.
The closing ?> tag MUST be omitted from files containing only PHP.
MUST use 4 spaces for indentation, not tabs
http://bit.ly/PSR-2
Tuesday, 26 February 13
![Page 55: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/55.jpg)
Should you PSR-2?
PSR-0 and PSR-1 are no brainers
PSR-2 was split from PSR-1 as its controversial
Tabs v Spaces? I don’t care.
Laravel is PSR-2ish
Tuesday, 26 February 13
![Page 56: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/56.jpg)
codeigniter-oauth2
fuel-oauth2
laravel-oauth2
Tuesday, 26 February 13
![Page 57: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/57.jpg)
Interfaces for the Win
Tuesday, 26 February 13
![Page 58: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/58.jpg)
Framework Driver Basics
interface SessionInterface { public function getKey(); public function put($value); public function get(); public function forget();}
Tuesday, 26 February 13
![Page 59: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/59.jpg)
Framework Driver Basics
use Fuel\Core\Session_Driver as Session;
class FuelPHPSession implements SessionInterface
class NativeSession implements SessionInterface
use CI_Session as Session;
class CISession implements SessionInterface
use Illuminate\Session\Store as SessionStore;
class IlluminateSession implements SessionInterface
Tuesday, 26 February 13
![Page 60: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/60.jpg)
Framework Driver Basics
use CI_Session as Session;
class CISession implements SessionInterface{ public function __construct(Session $store) { $this->store = $store; } }
Tuesday, 26 February 13
![Page 61: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/61.jpg)
Framework Driver Basics public function put($value) { $this->store->set_userdata(
$this->getkey(),serialize($value));
}
public function forget() { $this->store->unset_userdata(
$this->getKey());
}
Tuesday, 26 February 13
![Page 62: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/62.jpg)
Tuesday, 26 February 13
![Page 63: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/63.jpg)
PyroCMS
PyroCMS 2.2 = PHP 5.2 + CodeIgniter
PyroCMS 2.3 = PHP 5.3 + Composer + CodeIgniter
PyroCMS 3.0 = PHP 5.3 + Composer + Laravel
Tuesday, 26 February 13
![Page 64: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/64.jpg)
PyroCMS Depenencies dflydev/markdowndhorrigan/capsuleircmaxell/password-compatilluminate/databasenesbot/Carbonquick/cachesimplepie/simplepietijsverkoyen/akismet
Tuesday, 26 February 13
![Page 65: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/65.jpg)
Any Questions?
What was that thing you said about PSR?
Are you Australian?
Is camelCase web-scale?
Do you prefer Tabs or Spaces?
Why doesn’t PyroCMS support MongoDB?
Tuesday, 26 February 13
![Page 66: Laravel and Composer](https://reader036.fdocuments.net/reader036/viewer/2022062307/554a0f52b4c905825d8b48fd/html5/thumbnails/66.jpg)
Thank You
philsturgeon.co.uk
github.com/philsturgeon
@philsturgeon
Tuesday, 26 February 13