SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
Compose all the things
                             @philsturgeon




Tuesday, 26 February 13
Derp derpy derp!

                   Kapture              PHP The Right Way

                   PyroCMS              PHP Town Hall

                   CodeIgniter          PHP-FIG

                   FuelPHP              I have a weird accent

                   PancakeApp           @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
Installing stuff with PEAR


         sudo apt-get install php-pear php5-dev

         sudo pear channel-discover pear.phpunit.de

         sudo pear install phpunit/PHPUnit




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
                                       CodeIgniter
                          DATABAZE!!            Encryption

                          Benchmarking          Uploads

                          Cache                 Image Manipulation

                          Calender              Language

                          Email                 Pagination

                          Shopping Cart?        Security

Tuesday, 26 February 13
Tuesday, 26 February 13
Tuesday, 26 February 13
Write ALL THE CODE
                      Kohana       CodeIgniter
                      Benchmarking
                       ORM                  Encryption
                       HTTP
                      Cache                 Uploads
                       UTF-8
                      Calender              Image Manipulation
                     Templates
                       HMVC
                      Cart                  Language

                          Driver            Pagination

                          Email             Security

Tuesday, 26 February 13
Write ALL THE CODE
                      Kohana      CodeIgniter
                      Benchmarking
                       ORM                  Encryption
                                     FuelPHP
                       HTTP
                      Cache           REST Uploads
                       UTF-8       Scaffolding
                      Calender              Image Manipulation
                     Templates      Migrations
                       HMVC
                      Cart             Auth Language
                      Driver       More Mongo
                                            Pagination

                          Email             Security

Tuesday, 26 February 13
Write ALL THE CODE
                      Kohana     CodeIgniter
                      Benchmarking
                       ORM                  Encryption
                                     FuelPHP
                       HTTP
                      Cache           REST Uploads
                       UTF-8       Scaffolding
                      Calender              Image Manipulation
                     Templates      Migrations      Laravel 3
                       HMVC
                      Cart             Auth Language Routes
                                                   Epic
                      Driver       More Mongo CALLBACKS
                                            Pagination
                                                        IoC
                      Email                 Security Bundles

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/framework


          https://github.com/laravel/laravel/tree/develop


                              https://github.com/illuminate


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": {
                             "EpicUnicorn": "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-0
                          Autoloading 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-1
                          Basic 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-2
                          Coding 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
    class NativeSession implements SessionInterface

    use CI_Session as Session;

    class CISession implements SessionInterface


   use FuelCoreSession_Driver as Session;

   class FuelPHPSession implements SessionInterface


    use IlluminateSessionStore 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/markdown
                             dhorrigan/capsule
                             ircmaxell/password-compat
                             illuminate/database
                             nesbot/Carbon
                             quick/cache
                             simplepie/simplepie
                             tijsverkoyen/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

                            philsturgeon.co.uk

                          github.com/philsturgeon




Tuesday, 26 February 13

Weitere ähnliche Inhalte

Andere mochten auch

Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialJoe Ferguson
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$Joe Ferguson
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$Joe Ferguson
 
Hire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel ProgrammersHire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel ProgrammersSummation IT
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 Joe Ferguson
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.SWAAM Tech
 
Intro to Laravel PHP Framework
Intro to Laravel PHP FrameworkIntro to Laravel PHP Framework
Intro to Laravel PHP FrameworkBill Condo
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 

Andere mochten auch (11)

Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
10 Awesome Websites Built With Laravel Framework
10 Awesome Websites Built With Laravel Framework10 Awesome Websites Built With Laravel Framework
10 Awesome Websites Built With Laravel Framework
 
Hire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel ProgrammersHire laravel-php-developers- Hire Laravel Programmers
Hire laravel-php-developers- Hire Laravel Programmers
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.
 
Intro to Laravel PHP Framework
Intro to Laravel PHP FrameworkIntro to Laravel PHP Framework
Intro to Laravel PHP Framework
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 

Ähnlich wie Laravel and Composer

Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBossJBug Italy
 
Make your cheap VM fly
Make your cheap VM flyMake your cheap VM fly
Make your cheap VM flyCode Enigma
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking systemJesse Vincent
 
44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON
 
Riak intro to..
Riak intro to..Riak intro to..
Riak intro to..Adron Hall
 
Automatic Configuration of Your Cloud with Puppet
Automatic Configuration of Your Cloud with PuppetAutomatic Configuration of Your Cloud with Puppet
Automatic Configuration of Your Cloud with PuppetPuppet
 
Cloud building talk
Cloud building talkCloud building talk
Cloud building talkbodepd
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingPerl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingVlatko Kosturjak
 
Crypto With OpenSSL
Crypto With OpenSSLCrypto With OpenSSL
Crypto With OpenSSLZhi Guan
 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinJoshua Long
 
Workshop de Ruby on Rails
Workshop de Ruby on RailsWorkshop de Ruby on Rails
Workshop de Ruby on RailsFabio Akita
 
Ruby and Framework Security
Ruby and Framework SecurityRuby and Framework Security
Ruby and Framework SecurityCreston Jamison
 
Deploying JRuby Web Applications
Deploying JRuby Web ApplicationsDeploying JRuby Web Applications
Deploying JRuby Web ApplicationsJoe Kutner
 
Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyJoe Kutner
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache CamelFuseSource.com
 
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]Jason Rhodes
 
Backend as a Service
Backend as a ServiceBackend as a Service
Backend as a ServiceLutz Kohl
 

Ähnlich wie Laravel and Composer (20)

Html5 apis
Html5 apisHtml5 apis
Html5 apis
 
Camel and JBoss
Camel and JBossCamel and JBoss
Camel and JBoss
 
Make your cheap VM fly
Make your cheap VM flyMake your cheap VM fly
Make your cheap VM fly
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train44CON London 2015 - Going AUTH the Rails on a Crazy Train
44CON London 2015 - Going AUTH the Rails on a Crazy Train
 
Riak intro to..
Riak intro to..Riak intro to..
Riak intro to..
 
Automatic Configuration of Your Cloud with Puppet
Automatic Configuration of Your Cloud with PuppetAutomatic Configuration of Your Cloud with Puppet
Automatic Configuration of Your Cloud with Puppet
 
Cloud building talk
Cloud building talkCloud building talk
Cloud building talk
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingPerl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testing
 
Crypto With OpenSSL
Crypto With OpenSSLCrypto With OpenSSL
Crypto With OpenSSL
 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and Vaadin
 
Workshop de Ruby on Rails
Workshop de Ruby on RailsWorkshop de Ruby on Rails
Workshop de Ruby on Rails
 
Fabric: A Capistrano Alternative
Fabric:  A Capistrano AlternativeFabric:  A Capistrano Alternative
Fabric: A Capistrano Alternative
 
Ruby and Framework Security
Ruby and Framework SecurityRuby and Framework Security
Ruby and Framework Security
 
Deploying JRuby Web Applications
Deploying JRuby Web ApplicationsDeploying JRuby Web Applications
Deploying JRuby Web Applications
 
Deploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRubyDeploy, Scale and Sleep at Night with JRuby
Deploy, Scale and Sleep at Night with JRuby
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
The WordPress Hacker's Guide to the \Galaxy() [@MidwestPHP]
 
Backend as a Service
Backend as a ServiceBackend as a Service
Backend as a Service
 
Lumen
LumenLumen
Lumen
 

Mehr von Phil Sturgeon

API Pain Points (PHPNE)
API Pain Points (PHPNE)API Pain Points (PHPNE)
API Pain Points (PHPNE)Phil Sturgeon
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePhil Sturgeon
 
Become Master of Your Own Universe - DIBI 2013
Become Master of Your Own Universe - DIBI 2013Become Master of Your Own Universe - DIBI 2013
Become Master of Your Own Universe - DIBI 2013Phil Sturgeon
 
Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Phil Sturgeon
 
Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to FuelPhil Sturgeon
 
Running an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectRunning an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectPhil Sturgeon
 

Mehr von Phil Sturgeon (10)

API Pain Points (PHPNE)
API Pain Points (PHPNE)API Pain Points (PHPNE)
API Pain Points (PHPNE)
 
Api pain points
Api pain pointsApi pain points
Api pain points
 
Api pain points
Api pain pointsApi pain points
Api pain points
 
PHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and FuturePHP-FIG: Past, Present and Future
PHP-FIG: Past, Present and Future
 
Become Master of Your Own Universe - DIBI 2013
Become Master of Your Own Universe - DIBI 2013Become Master of Your Own Universe - DIBI 2013
Become Master of Your Own Universe - DIBI 2013
 
Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4Why I &lt;3 Laravel 4
Why I &lt;3 Laravel 4
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Cms expo
Cms expoCms expo
Cms expo
 
Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to Fuel
 
Running an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectRunning an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter project
 

Laravel and Composer

  • 1. Compose all the things @philsturgeon Tuesday, 26 February 13
  • 2. Derp derpy derp! Kapture PHP The Right Way PyroCMS PHP Town Hall CodeIgniter PHP-FIG FuelPHP I have a weird accent PancakeApp @philsturgeon Tuesday, 26 February 13
  • 3. “I could spend 10 minutes writing some code, but [stuff] that, I can just install a Gem.” -- Elliott Kember, RiotHQ Tuesday, 26 February 13
  • 4. 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
  • 5. 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
  • 8. What about PHP? Tuesday, 26 February 13
  • 12. Installing stuff with PEAR sudo apt-get install php-pear php5-dev sudo pear channel-discover pear.phpunit.de sudo pear install phpunit/PHPUnit Tuesday, 26 February 13
  • 13. Cool story bro Tuesday, 26 February 13
  • 20. The Dawn of Frameworks! Tuesday, 26 February 13
  • 24. Write ALL THE CODE CodeIgniter DATABAZE!! Encryption Benchmarking Uploads Cache Image Manipulation Calender Language Email Pagination Shopping Cart? Security Tuesday, 26 February 13
  • 27. Write ALL THE CODE Kohana CodeIgniter Benchmarking ORM Encryption HTTP Cache Uploads UTF-8 Calender Image Manipulation Templates HMVC Cart Language Driver Pagination Email Security Tuesday, 26 February 13
  • 28. Write ALL THE CODE Kohana CodeIgniter Benchmarking ORM Encryption FuelPHP HTTP Cache REST Uploads UTF-8 Scaffolding Calender Image Manipulation Templates Migrations HMVC Cart Auth Language Driver More Mongo Pagination Email Security Tuesday, 26 February 13
  • 29. Write ALL THE CODE Kohana CodeIgniter Benchmarking ORM Encryption FuelPHP HTTP Cache REST Uploads UTF-8 Scaffolding Calender Image Manipulation Templates Migrations Laravel 3 HMVC Cart Auth Language Routes Epic Driver More Mongo CALLBACKS Pagination IoC Email Security Bundles Tuesday, 26 February 13
  • 30. FW Packages = Solution? CodeIgniter: Sparks FuelPHP: Cells Laravel 3: Bundles Tuesday, 26 February 13
  • 31. codeigniter-oauth2 fuel-oauth2 laravel-oauth2 Tuesday, 26 February 13
  • 34. Composer Setup $ mkdir playground $ cd playground $ curl -s https://getcomposer.org/installer | php $ ls composer.phar $ vim composer.json Tuesday, 26 February 13
  • 35. Require Packages { "minimum-stability": "beta", "require": { "dflydev/markdown": "1.0.*", "illuminate/database": "*" } } Tuesday, 26 February 13
  • 36. 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
  • 37. 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
  • 39. 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
  • 42. Where is Laravel 4 https://github.com/laravel/framework https://github.com/laravel/laravel/tree/develop https://github.com/illuminate Tuesday, 26 February 13
  • 43. Cloning Laravel 4 $ git clone git://github.com/laravel/laravel.git -o laravel -b develop playground Tuesday, 26 February 13
  • 44. Install Dependencies $ cd playground $ curl -s https://getcomposer.org/installer | php $ ./composer.phar install Tuesday, 26 February 13
  • 45. 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
  • 47. 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
  • 48. 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": { "EpicUnicorn": "src/" } }, "minimum-stability": "dev" } Tuesday, 26 February 13
  • 49. Unit-tests phpunit.de travis-ci.org Tuesday, 26 February 13
  • 50. .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
  • 51. 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
  • 52. PSR-0 Autoloading 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
  • 53. PSR-1 Basic 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
  • 54. PSR-2 Coding 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
  • 55. 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
  • 56. codeigniter-oauth2 fuel-oauth2 laravel-oauth2 Tuesday, 26 February 13
  • 57. Interfaces for the Win Tuesday, 26 February 13
  • 58. Framework Driver Basics interface SessionInterface { public function getKey(); public function put($value); public function get(); public function forget(); } Tuesday, 26 February 13
  • 59. Framework Driver Basics class NativeSession implements SessionInterface use CI_Session as Session; class CISession implements SessionInterface use FuelCoreSession_Driver as Session; class FuelPHPSession implements SessionInterface use IlluminateSessionStore as SessionStore; class IlluminateSession implements SessionInterface Tuesday, 26 February 13
  • 60. Framework Driver Basics use CI_Session as Session; class CISession implements SessionInterface { public function __construct(Session $store) { $this->store = $store; } } Tuesday, 26 February 13
  • 61. 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
  • 63. 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
  • 64. PyroCMS Depenencies dflydev/markdown dhorrigan/capsule ircmaxell/password-compat illuminate/database nesbot/Carbon quick/cache simplepie/simplepie tijsverkoyen/akismet Tuesday, 26 February 13
  • 65. 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
  • 66. Thank You @philsturgeon philsturgeon.co.uk github.com/philsturgeon Tuesday, 26 February 13