Post on 06-May-2015
description
transcript
Compose all the things@philsturgeon
Tuesday, 26 February 13
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
“I could spend 10 minutes writing some code, but [stuff] that, I can just install a Gem.”
-- Elliott Kember, RiotHQ
Tuesday, 26 February 13
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
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
Tuesday, 26 February 13
Tuesday, 26 February 13
What about PHP?
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
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
Cool story bro
Tuesday, 26 February 13
“Active Package”
Tuesday, 26 February 13
“Modern Package”
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
The Dawn of Frameworks!
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Write ALL THE CODE
DATABAZE!!
Benchmarking
Cache
Calender
Shopping Cart?
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniter
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Write ALL THE CODE
Benchmarking
Cache
Calender
Cart
Driver
Encryption
Uploads
Image Manipulation
Language
Pagination
Security
CodeIgniterKohanaORMHTTPUTF-8
TemplatesHMVC
Tuesday, 26 February 13
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
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
FW Packages = Solution?
CodeIgniter: Sparks
FuelPHP: Cells
Laravel 3: Bundles
Tuesday, 26 February 13
codeigniter-oauth2
fuel-oauth2
laravel-oauth2
Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Composer Setup
$ mkdir playground
$ cd playground
$ curl -s https://getcomposer.org/installer | php
$ ls
composer.phar
$ vim composer.json
Tuesday, 26 February 13
Require Packages
{
"minimum-stability": "beta",
"require": {
"dflydev/markdown": "1.0.*",
"illuminate/database": "*"
}
}
Tuesday, 26 February 13
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
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
Tuesday, 26 February 13
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
Tuesday, 26 February 13
Tuesday, 26 February 13
Where is Laravel 4
https://github.com/laravel/laravel/tree/develop
https://github.com/illuminate
https://github.com/laravel/framework
Tuesday, 26 February 13
Cloning Laravel 4
$ git clone git://github.com/laravel/laravel.git
-o laravel -b develop playground
Tuesday, 26 February 13
Install Dependencies
$ cd playground
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar install
Tuesday, 26 February 13
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 address?email@philsturgeon.co.uk
Tuesday, 26 February 13
Understanding Structure
Tuesday, 26 February 13
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
Metadata{
"name": "epic/unicorn", "authors": [ { "name": "Phil Sturgeon", "email": "email@philsturgeon.co.uk" } ], "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
Unit-tests
phpunit.de
travis-ci.org
Tuesday, 26 February 13
.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
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
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
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
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
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
codeigniter-oauth2
fuel-oauth2
laravel-oauth2
Tuesday, 26 February 13
Interfaces for the Win
Tuesday, 26 February 13
Framework Driver Basics
interface SessionInterface { public function getKey(); public function put($value); public function get(); public function forget();}
Tuesday, 26 February 13
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
Framework Driver Basics
use CI_Session as Session;
class CISession implements SessionInterface{ public function __construct(Session $store) { $this->store = $store; } }
Tuesday, 26 February 13
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
Tuesday, 26 February 13
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
PyroCMS Depenencies dflydev/markdowndhorrigan/capsuleircmaxell/password-compatilluminate/databasenesbot/Carbonquick/cachesimplepie/simplepietijsverkoyen/akismet
Tuesday, 26 February 13
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
Thank You
philsturgeon.co.uk
github.com/philsturgeon
@philsturgeon
Tuesday, 26 February 13