SlideShare uma empresa Scribd logo
1 de 40
lithium
                          use lithiumcoreObject;




Friday, February 17, 12                               1
the agenda
                   •      introductions
                   •      Lithium’s goals
                   •      the framework today
                   •      examples!
                   •      poster children
                   •      it’s all over


Friday, February 17, 12                         2
introductions
                             var_dump($this);




Friday, February 17, 12                         3
introduction - john anderson
                   •      first web related work was in 1995 (perl/html/js)
                   •      b.s. in information tech @ byu
                   •      cakephp core team
                   •      director of technology at (media)rain
                   •      lithium core team, founding member
                   •      software engineer, adobe systems


Friday, February 17, 12                                                       4
introduction - lithium
                   •      started as some test scripts on early 5.3 builds
                          •   namespacing, closures, lsb, __magic(), PHAR
                   •      released as “cake3” in july ’09
                   •      released as “lithium” (li3) in oct ’09
                   •      based on 5 years of learning on a high-adoption
                          framework (cakephp).



Friday, February 17, 12                                                      5
lithium today
                          new lithiumcoreObject(time());




Friday, February 17, 12                                       6
lithium today
                   •      130 plugins on github
                   •      350 commits from 40 contributors since 0.10
                   •      60 commits to the manual since 0.10 (woot)
                   •      250 closed github issues
                   •      latest additions:
                          •   csrf protection, cookie signing, error handler, ...


Friday, February 17, 12                                                             7
goals
                          abstract class Lithium {}




Friday, February 17, 12                               8
lithium sucks
                   •      Not like this -->




Friday, February 17, 12                       9
lithium sucks
                   •      Like this:
                          •   there’s code in there you don’t use.
                          •   complexity overhead.
                          •   you didn’t write it.
                          •   it’s a framework.




Friday, February 17, 12                                              10
we try to suck less
                   •      Do things the php way
                   •      no paradigm/pattern hubris
                   •      great architecture
                   •      as simple as possible




Friday, February 17, 12                                11
the php way
                     •         example: sf dependency injection (Zend mailer)
                     •         Starts like this:
                           1   <?php
                           2
                           3   $transport =          new Zend_Mail_Transport_Smtp('smtp.gmail.com', array(
                           4     'auth'              => 'login',
                           5     'username'          => 'foo',
                           6     'password'          => 'bar',
                           7     'ssl'               => 'ssl',
                           8     'port'              => 465,
                           9   ));
                          10
                          11   $mailer = new Zend_Mail();
                          12   $mailer->setDefaultTransport($transport);



                          * examples taken from http://components.symfony-project.org/dependency-injection/documentation




Friday, February 17, 12                                                                                                    12
the php way
                     •             ends up like this:
                     •             (This doesn’t include the xml service descriptor)
                           1   <?php
                           2
                           3   class Container extends sfServiceContainer
                           4   {
                           5     static protected $shared = array();
                           6
                           7       protected function getMailTransportService()
                           8       {
                           9         return new Zend_Mail_Transport_Smtp('smtp.gmail.com', array(
                          10           'auth'     => 'login',
                          11           'username' => $this['mailer.username'],
                          12           'password' => $this['mailer.password'],
                          13           'ssl'      => 'ssl',
                          14           'port'     => 465,
                          15         ));
                          16       }
                          17
                          18       protected function getMailerService()
                          19       {
                          20         if (isset(self::$shared['mailer']))
                          21         {
                          22           return self::$shared['mailer'];
                          23         }
                          24
                          25           $class = $this['mailer.class'];
                          26
                          27           $mailer = new $class();
                          28           $mailer->setDefaultTransport($this->getMailTransportService());
                          29
                          30           return self::$shared['mailer'] = $mailer;
                          31       }
                          32   }

Friday, February 17, 12                                                                                  13
the php way



                          1 <?php
                          2
                          3 mail(...);




Friday, February 17, 12                  14
patters and paradigms
                   •      OOP √

                   •      aspect-oriented √

                   •      procedural √

                   •      functional √

                   •      declarative √




Friday, February 17, 12                       15
good architecture
                   •      logical namespaces and classes
                          •   yay for PSR-0!
                              •   Vendornamespace...class
                   •      unified constructors with < 3 params
                   •      adaptable strategies
                   •      aspect-oriented method filtering


Friday, February 17, 12                                          16
examples
                          /**
                           * Let’s do this thing.
                           */




Friday, February 17, 12                             17
Configuration
                   •        Here’s what the webroot’s index.php looks like:
                   •        (Minus comments!)

                          1 <?php
                          2
                          3 require dirname(__DIR__) . '/config/bootstrap.php';
                          4
                          5 echo lithiumactionDispatcher::run(new lithiumactionRequest());




Friday, February 17, 12                                                                          18
configuration
                   •          simple:
                          1   <?php
                          2
                          3   require dirname(__DIR__) . '/bootstrap/libraries.php';
                          4
                          5   require dirname(__DIR__) . '/bootstrap/connections.php';
                          6
                          7   ...

                     * easily supports multiple environments!




Friday, February 17, 12                                                                  19
Unified simple construction
                   •      objects use a unified constructor
                   •      single $config param, automatically sets whitelisted
                          properties
                   •      automatically calls init
                          •   allows for very light construction
                          •   leaves init to its own (optional!) method



Friday, February 17, 12                                                          20
unified simple construction
                      1   <?php
                      2   namespace app/extensions;
                      3
                      4   use lithiumnethttpService;
                      5
                      6   class Foo extends lithiumcoreObject {
                      7       public $service;
                      8
                      9        public function __construct(array $config = array()) {
                     10            $defaults = array(
                     11                'foo' => 'bar'
                     12            );
                     13            parent::__construct($config + $defaults);
                     14        }
                     15
                     16        public function _init() {
                     17            parent::_init();
                     18            $this->service = new Service();
                     19        }
                     20
                     21        public function baz() {
                     22            echo $this->_config['foo'];
                     23        }
                     24   }
                     25   ?>




Friday, February 17, 12                                                                 21
unified simple construction
                      1   <?php
                      2   use appextensionsFoo;
                      3
                      4   $foo = new Foo();
                      5   $foo->baz();                 // 'bar'
                      6
                      7   $foo2 = new Foo(array(
                      8       'foo' => '123'
                      9   ));
                     10   $foo2->baz();                // '123'
                     11
                     12   $foo3 = new Foo(array(
                     13       'init' => 'false'
                     14   ));
                     15   get_class($foo3->service);    // PHP Warning...
                     16
                     17   get_class($foo->service);    // 'lithiumnethttpService'
                     18   ?>




Friday, February 17, 12                                                                22
Aop filters
                   •      allow you to easily wrap your logic before or after
                          core class methods
                   •      original logic is wrapped in a closure
                   •      all logic is chained and run in sequence
                   •      filters allow you to inject logic into the chain




Friday, February 17, 12                                                         23
Aop filters
                   •      no more before+x, after+x in the api
                   •      allows many more methods to be filterable
                   •      no more stomping on callbacks in extended classes
                   •      allows you to inject logic into the chain multiple times,
                          or from different places
                   •      much easier to address and organize “cross-cutting”
                          concerns


Friday, February 17, 12                                                               24
model filter example
                      1 <?php
                      2
                      3 Users::applyFilter('save', function($self, $params, $chain) {
                      4     // For newly created users:
                      5   if (!$params['entity']->exists() && $params['entity']->validates()) {
                      6
                      7     // Hash new user passwords and set 'created' date
                      8     $params['entity']->password = Password::hash($params['entity']->password);
                      9     $params['entity']->created_at = new MongoDate();
                     10     $params['entity']->created_by = $user['email'];
                     11   }
                     12
                     13   // Set modified info
                     14   $params['entity']->modified_at = new MongoDate();
                     15   $params['entity']->modified_by = $user['email'];
                     16
                     17   return $chain->next($self, $params, $chain);
                     18 });




Friday, February 17, 12                                                                                  25
usage examples
                   •      controllers
                          •   permissions
                   •      models
                          •   Logging/caching
                          •   über customized validation
                          •   external-to-db resource cleanup



Friday, February 17, 12                                         26
filtering as service layers
                              logging
                              caching
                              finding




Friday, February 17, 12                          27
dependency injection
                   •      these aren’t the droids you’re looking for
                   •      long story short - allows you to pick and choose your
                          dependencies at runtime rather than at compile time
                   •      For instance, rather than hard-coding a logger class
                          that a user model will use, allow di to switch that out
                          at runtime
                   •      i.e. = woo now we gots growl notifications



Friday, February 17, 12                                                             28
dependency injection
                   •      remember the di example we started with?
                          •   the logic
                          •   and its container
                          •   and its service container parent
                          •   and its xml service description
                   •      li3 uses class properties instead.



Friday, February 17, 12                                              29
di made simple
                      1   <?php
                      2
                      3   class Service extends lithiumcoreObject {
                      4     protected $_classes = array(
                      5        'request' => 'lithiumnethttpRequest',
                      6        'response' => 'lithiumnethttpResponse',
                      7     );
                      8   }
                      9
                     10   $service = new Service(array('classes' => array(
                     11     'request' => 'foobarRequest'
                     12   )))




Friday, February 17, 12                                                      30
adaptable
                   •      allows for configuration of main class purposes
                   •      adaptable classes:
                          •   auth (form, http)
                          •   cache (memcached, apc, file...)
                          •   logger (growl, syslog, file...)
                          •   session (cookie, php, memory...)



Friday, February 17, 12                                                     31
adaptable
                   •       consistent class configuration
                      1   <?php
                      2
                      3   use lithiumstorageCache;
                      4
                      5   Cache::config(array(
                      6     'default' => array( // configuration name
                      7       'development' => array( // environment name
                      8          'adapter' => 'Apc',
                      9       ),
                     10       'production' => array( // woo another environment name
                     11          'adapter' => 'Memcached',
                     12          'servers' => array('127.0.0.1'), // custom vars handed to adapter constructor
                     13       )
                     14     )
                     15   ));




Friday, February 17, 12                                                                                          32
poster children
                              $this->horn->toot();
                             Authority::appealTo();




Friday, February 17, 12                               33
•   sean coates

                                     •    ed finkler

                                     •   chris shiflett

                                     •     mongodb




                          gimmebar
Friday, February 17, 12                                   34
•   chris shiflett

                                  •   Andrei Zmievski




                          totsy
Friday, February 17, 12                                 35
Quotes
                  “After looking at Lithium, I’ve come to
                  realize how far ahead it is compared to
                  other frameworks from a technologist’s
                  point of view.”
                                —David Coallier, President of PEAR, CTO for Orchestra.IO (now Engine Yard)




Friday, February 17, 12                                                                                      36
Quotes

                  “It’s the F****** epiphany of modern!”
                                        —Helgi Þormar Þorbjörnsson, PEAR Core DEV




Friday, February 17, 12                                                             37
Quotes

                  “I believe the future is in lithium. Give it
                  time to grow, and the developers behind
                  it are awesome.”
                                         —Fahad Ibnay Heylaal, Creator Croogo (CakePHP) CMS




Friday, February 17, 12                                                                       38
thanks
                           exit(0);




Friday, February 17, 12               39
contact Me
                 @raisinbread
                 anderson.johnd@gmail.com


                  learn more
                 @unionofrad
                 github.com/UnionOfRAD
                 lithify.me
                 #li3 on Freenode

Friday, February 17, 12                     40

Mais conteúdo relacionado

Mais procurados

BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...panagenda
 
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal CodeKathy Brown
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on InfinispanLance Ball
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystJay Shirley
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Services web RESTful
Services web RESTfulServices web RESTful
Services web RESTfulgoldoraf
 
Plugin Memcached%20 Study
Plugin Memcached%20 StudyPlugin Memcached%20 Study
Plugin Memcached%20 StudyLiu Lizhi
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用iammutex
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5Stephan Schmidt
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with nettyZauber
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersLorna Mitchell
 
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...Dave Stokes
 

Mais procurados (20)

BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
BP107: Ten Lines Or Less: Interesting Things You Can Do In Java With Minimal ...
 
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
10 Lines or Less; Interesting Things You Can Do In Java With Minimal Code
 
DataMapper on Infinispan
DataMapper on InfinispanDataMapper on Infinispan
DataMapper on Infinispan
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and Catalyst
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
Php on Windows
Php on WindowsPhp on Windows
Php on Windows
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Services web RESTful
Services web RESTfulServices web RESTful
Services web RESTful
 
Plugin Memcached%20 Study
Plugin Memcached%20 StudyPlugin Memcached%20 Study
Plugin Memcached%20 Study
 
Memcached
MemcachedMemcached
Memcached
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
PHP And Web Services: Perfect Partners
PHP And Web Services: Perfect PartnersPHP And Web Services: Perfect Partners
PHP And Web Services: Perfect Partners
 
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...PHP,  The X DevAPI,  and the  MySQL Document Store Presented January 23rd, 20...
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
 

Semelhante a UPHPU Meeting, February 17, 2012

PHP Streams
PHP StreamsPHP Streams
PHP StreamsG Woo
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for RubyHiroshi SHIBATA
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetNan Liu
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toAlexander Makarov
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redisjimbojsb
 
Data processing with celery and rabbit mq
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mqJeff Peck
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP ApplicationsPavan Kumar N
 
Writing Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason LeeWriting Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason Leejaxconf
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyBlazing Cloud
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Martijn Verburg
 
Lessons from a Dying CMS
Lessons from a Dying CMSLessons from a Dying CMS
Lessons from a Dying CMSSandy Smith
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Adam Tomat
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled BundlerHiroshi SHIBATA
 
GitHub Notable OSS Project
GitHub  Notable OSS ProjectGitHub  Notable OSS Project
GitHub Notable OSS Projectroumia
 

Semelhante a UPHPU Meeting, February 17, 2012 (20)

Perl Intro 6 Ftp
Perl Intro 6 FtpPerl Intro 6 Ftp
Perl Intro 6 Ftp
 
PHP Streams
PHP StreamsPHP Streams
PHP Streams
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with Puppet
 
Building Custom PHP Extensions
Building Custom PHP ExtensionsBuilding Custom PHP Extensions
Building Custom PHP Extensions
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading to
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
Data processing with celery and rabbit mq
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mq
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
Writing Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason LeeWriting Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason Lee
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_many
 
Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)Back to the future with Java 7 (Geekout June/2011)
Back to the future with Java 7 (Geekout June/2011)
 
Lessons from a Dying CMS
Lessons from a Dying CMSLessons from a Dying CMS
Lessons from a Dying CMS
 
Per beginners2
Per beginners2Per beginners2
Per beginners2
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018
 
The Future of Bundled Bundler
The Future of Bundled BundlerThe Future of Bundled Bundler
The Future of Bundled Bundler
 
GitHub Notable OSS Project
GitHub  Notable OSS ProjectGitHub  Notable OSS Project
GitHub Notable OSS Project
 

Último

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Último (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

UPHPU Meeting, February 17, 2012

  • 1. lithium use lithiumcoreObject; Friday, February 17, 12 1
  • 2. the agenda • introductions • Lithium’s goals • the framework today • examples! • poster children • it’s all over Friday, February 17, 12 2
  • 3. introductions var_dump($this); Friday, February 17, 12 3
  • 4. introduction - john anderson • first web related work was in 1995 (perl/html/js) • b.s. in information tech @ byu • cakephp core team • director of technology at (media)rain • lithium core team, founding member • software engineer, adobe systems Friday, February 17, 12 4
  • 5. introduction - lithium • started as some test scripts on early 5.3 builds • namespacing, closures, lsb, __magic(), PHAR • released as “cake3” in july ’09 • released as “lithium” (li3) in oct ’09 • based on 5 years of learning on a high-adoption framework (cakephp). Friday, February 17, 12 5
  • 6. lithium today new lithiumcoreObject(time()); Friday, February 17, 12 6
  • 7. lithium today • 130 plugins on github • 350 commits from 40 contributors since 0.10 • 60 commits to the manual since 0.10 (woot) • 250 closed github issues • latest additions: • csrf protection, cookie signing, error handler, ... Friday, February 17, 12 7
  • 8. goals abstract class Lithium {} Friday, February 17, 12 8
  • 9. lithium sucks • Not like this --> Friday, February 17, 12 9
  • 10. lithium sucks • Like this: • there’s code in there you don’t use. • complexity overhead. • you didn’t write it. • it’s a framework. Friday, February 17, 12 10
  • 11. we try to suck less • Do things the php way • no paradigm/pattern hubris • great architecture • as simple as possible Friday, February 17, 12 11
  • 12. the php way • example: sf dependency injection (Zend mailer) • Starts like this: 1 <?php 2 3 $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', array( 4 'auth' => 'login', 5 'username' => 'foo', 6 'password' => 'bar', 7 'ssl' => 'ssl', 8 'port' => 465, 9 )); 10 11 $mailer = new Zend_Mail(); 12 $mailer->setDefaultTransport($transport); * examples taken from http://components.symfony-project.org/dependency-injection/documentation Friday, February 17, 12 12
  • 13. the php way • ends up like this: • (This doesn’t include the xml service descriptor) 1 <?php 2 3 class Container extends sfServiceContainer 4 { 5 static protected $shared = array(); 6 7 protected function getMailTransportService() 8 { 9 return new Zend_Mail_Transport_Smtp('smtp.gmail.com', array( 10 'auth' => 'login', 11 'username' => $this['mailer.username'], 12 'password' => $this['mailer.password'], 13 'ssl' => 'ssl', 14 'port' => 465, 15 )); 16 } 17 18 protected function getMailerService() 19 { 20 if (isset(self::$shared['mailer'])) 21 { 22 return self::$shared['mailer']; 23 } 24 25 $class = $this['mailer.class']; 26 27 $mailer = new $class(); 28 $mailer->setDefaultTransport($this->getMailTransportService()); 29 30 return self::$shared['mailer'] = $mailer; 31 } 32 } Friday, February 17, 12 13
  • 14. the php way 1 <?php 2 3 mail(...); Friday, February 17, 12 14
  • 15. patters and paradigms • OOP √ • aspect-oriented √ • procedural √ • functional √ • declarative √ Friday, February 17, 12 15
  • 16. good architecture • logical namespaces and classes • yay for PSR-0! • Vendornamespace...class • unified constructors with < 3 params • adaptable strategies • aspect-oriented method filtering Friday, February 17, 12 16
  • 17. examples /** * Let’s do this thing. */ Friday, February 17, 12 17
  • 18. Configuration • Here’s what the webroot’s index.php looks like: • (Minus comments!) 1 <?php 2 3 require dirname(__DIR__) . '/config/bootstrap.php'; 4 5 echo lithiumactionDispatcher::run(new lithiumactionRequest()); Friday, February 17, 12 18
  • 19. configuration • simple: 1 <?php 2 3 require dirname(__DIR__) . '/bootstrap/libraries.php'; 4 5 require dirname(__DIR__) . '/bootstrap/connections.php'; 6 7 ... * easily supports multiple environments! Friday, February 17, 12 19
  • 20. Unified simple construction • objects use a unified constructor • single $config param, automatically sets whitelisted properties • automatically calls init • allows for very light construction • leaves init to its own (optional!) method Friday, February 17, 12 20
  • 21. unified simple construction 1 <?php 2 namespace app/extensions; 3 4 use lithiumnethttpService; 5 6 class Foo extends lithiumcoreObject { 7 public $service; 8 9 public function __construct(array $config = array()) { 10 $defaults = array( 11 'foo' => 'bar' 12 ); 13 parent::__construct($config + $defaults); 14 } 15 16 public function _init() { 17 parent::_init(); 18 $this->service = new Service(); 19 } 20 21 public function baz() { 22 echo $this->_config['foo']; 23 } 24 } 25 ?> Friday, February 17, 12 21
  • 22. unified simple construction 1 <?php 2 use appextensionsFoo; 3 4 $foo = new Foo(); 5 $foo->baz(); // 'bar' 6 7 $foo2 = new Foo(array( 8 'foo' => '123' 9 )); 10 $foo2->baz(); // '123' 11 12 $foo3 = new Foo(array( 13 'init' => 'false' 14 )); 15 get_class($foo3->service); // PHP Warning... 16 17 get_class($foo->service); // 'lithiumnethttpService' 18 ?> Friday, February 17, 12 22
  • 23. Aop filters • allow you to easily wrap your logic before or after core class methods • original logic is wrapped in a closure • all logic is chained and run in sequence • filters allow you to inject logic into the chain Friday, February 17, 12 23
  • 24. Aop filters • no more before+x, after+x in the api • allows many more methods to be filterable • no more stomping on callbacks in extended classes • allows you to inject logic into the chain multiple times, or from different places • much easier to address and organize “cross-cutting” concerns Friday, February 17, 12 24
  • 25. model filter example 1 <?php 2 3 Users::applyFilter('save', function($self, $params, $chain) { 4 // For newly created users: 5 if (!$params['entity']->exists() && $params['entity']->validates()) { 6 7 // Hash new user passwords and set 'created' date 8 $params['entity']->password = Password::hash($params['entity']->password); 9 $params['entity']->created_at = new MongoDate(); 10 $params['entity']->created_by = $user['email']; 11 } 12 13 // Set modified info 14 $params['entity']->modified_at = new MongoDate(); 15 $params['entity']->modified_by = $user['email']; 16 17 return $chain->next($self, $params, $chain); 18 }); Friday, February 17, 12 25
  • 26. usage examples • controllers • permissions • models • Logging/caching • über customized validation • external-to-db resource cleanup Friday, February 17, 12 26
  • 27. filtering as service layers logging caching finding Friday, February 17, 12 27
  • 28. dependency injection • these aren’t the droids you’re looking for • long story short - allows you to pick and choose your dependencies at runtime rather than at compile time • For instance, rather than hard-coding a logger class that a user model will use, allow di to switch that out at runtime • i.e. = woo now we gots growl notifications Friday, February 17, 12 28
  • 29. dependency injection • remember the di example we started with? • the logic • and its container • and its service container parent • and its xml service description • li3 uses class properties instead. Friday, February 17, 12 29
  • 30. di made simple 1 <?php 2 3 class Service extends lithiumcoreObject { 4 protected $_classes = array( 5 'request' => 'lithiumnethttpRequest', 6 'response' => 'lithiumnethttpResponse', 7 ); 8 } 9 10 $service = new Service(array('classes' => array( 11 'request' => 'foobarRequest' 12 ))) Friday, February 17, 12 30
  • 31. adaptable • allows for configuration of main class purposes • adaptable classes: • auth (form, http) • cache (memcached, apc, file...) • logger (growl, syslog, file...) • session (cookie, php, memory...) Friday, February 17, 12 31
  • 32. adaptable • consistent class configuration 1 <?php 2 3 use lithiumstorageCache; 4 5 Cache::config(array( 6 'default' => array( // configuration name 7 'development' => array( // environment name 8 'adapter' => 'Apc', 9 ), 10 'production' => array( // woo another environment name 11 'adapter' => 'Memcached', 12 'servers' => array('127.0.0.1'), // custom vars handed to adapter constructor 13 ) 14 ) 15 )); Friday, February 17, 12 32
  • 33. poster children $this->horn->toot(); Authority::appealTo(); Friday, February 17, 12 33
  • 34. sean coates • ed finkler • chris shiflett • mongodb gimmebar Friday, February 17, 12 34
  • 35. chris shiflett • Andrei Zmievski totsy Friday, February 17, 12 35
  • 36. Quotes “After looking at Lithium, I’ve come to realize how far ahead it is compared to other frameworks from a technologist’s point of view.” —David Coallier, President of PEAR, CTO for Orchestra.IO (now Engine Yard) Friday, February 17, 12 36
  • 37. Quotes “It’s the F****** epiphany of modern!” —Helgi Þormar Þorbjörnsson, PEAR Core DEV Friday, February 17, 12 37
  • 38. Quotes “I believe the future is in lithium. Give it time to grow, and the developers behind it are awesome.” —Fahad Ibnay Heylaal, Creator Croogo (CakePHP) CMS Friday, February 17, 12 38
  • 39. thanks exit(0); Friday, February 17, 12 39
  • 40. contact Me @raisinbread anderson.johnd@gmail.com learn more @unionofrad github.com/UnionOfRAD lithify.me #li3 on Freenode Friday, February 17, 12 40