SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
Digging Through the Guts of Enterprise PHP                                                             9/19/08 10:58 AM




      1.   Digging Through the Guts of Enterprise PHP
           A Case Study
           Shawn Lauriat
           IBM Rational Build Forge




      2.   Introductions
           Me
                 Advisory Engineer, Lead UI/G11N Developer @ IBM Rational Build Forge
                 Author, Advanced Ajax: Architectures and Best Practices
                 http://frozen-o.com/blog/
           Build Forge
                 quot;It automates and accelerates build and release processes through server pooling and fault
                 tolerance for Agile development and streamlined software delivery.quot;
                 a.k.a. process automation tool


      3.   Disclaimer
           The views expressed in this commentary are the author's own and do not necessarily reflect those of
           IBM.


      4.   Overview
           I will not:
                    Teach you to use PHP5 features

           I will:
                    Show PHP5 features' usefulness
                    Show PHP5 features in code
                    Show PHP5 features in action


      5.   Interfaces
http://localhost/enterpriseguts/                                                                              Page 1 of 6
Digging Through the Guts of Enterprise PHP                            9/19/08 10:58 AM




           class -> Instance Definition
           interface -> Instance Requirements Definition
           interface + type hinting

           = more stable code with less effort


      6.   BuildForge_Services_Serializable
           /** Used for object transportation */
           interface BuildForge_Services_Serializable {

                    /** @param array|null $data */
                    public function fromArray(array $data = null);

                    /** @return array */
                    public function toArray();

           }


      7.   BuildForge_Services_DBO_Snapshottable
           /** Create snapshot metadata */
           $snapshot = BuildForge_Services_DBO_Snapshot::createSnapshot(
               $services,
               quot;My New Snapshotquot;,
               quot;A Comment about My New Snapshotquot;
           );
           /** Get a new snapshot of the $originalOne */
           return $originalOne->snapshot(
               $snapshot->getUuid(),
               new BuildForge_Services_DBO_SnapshotRequest(true),
               false
           );


      8.   Inheritance
           BuildForge_Services_DBO_Project
http://localhost/enterpriseguts/                                            Page 2 of 6
Digging Through the Guts of Enterprise PHP                                             9/19/08 10:58 AM




                    Fields
                    Custom Methods
                    implements BuildForge_Services_DBO_Snapshottable
                    extends BuildForge_Services_UUIDDBO
                           ::getUuid()
                           ::isLive()
                           extends BuildForge_Services_DBO
                                  implements BuildForge_Services_Serializable
                                  ::__construct()


      9.   Iterators
           interface Iterator extends Traversable {
               function rewind();
               function current();
               function key();
               function next();
               function valid();
           }


    10.    Using Iterators for scalability
           The Class Tree
           Iterator

                    OuterIterator

                             BuildForge_Services_Iterator

                                     BuildForge_Services_ProjectIterator

                                             Iterator

                                                   BuildForge_Services_ValueIterator



    11.    Using Iterators for Scalability
           The Code

http://localhost/enterpriseguts/                                                             Page 3 of 6
Digging Through the Guts of Enterprise PHP                           9/19/08 10:58 AM



          class BuildForge_Services_DBO_ProjectIterator
                  extends BuildForge_Services_Iterator {
              public function current() {
                  $current = parent::current();
                  if (empty($current)) return $current;
                  $project = new BuildForge_Services_DBO_Project($this->conn);
                  $project->fromArray($current);
                  return $project;
              }
          }

          // Elsewhere in the app...
          $projects = BuildForge_Services_DBO_Project::iterateAll($services);
          foreach ($projects as $project) {
              // Do stuff
          }


    12.   Design Patterns




    13.   Model-View-Controller Code
          class Projects {
              public function render() {
                  $projects = BuildForge_Services_DBO_Project
http://localhost/enterpriseguts/                                           Page 4 of 6
Digging Through the Guts of Enterprise PHP                                         9/19/08 10:58 AM



                                         ::iterateFiltered(
                                     $this->services,
                                     $filter
                             );
                             $this->view->register_object('listing', $projects);
                    }
          }

          <tbody id=quot;listingquot;>
              <?php try {
                   foreach ($_['listing'] as $project_instance) {
                       print '<tr>';
                       // etc.
                       print '</tr>';
                   }
              } catch (Exception $e) { /* do something */ } ?>
          </tbody>


    14.   Observer to Track State
          class BuildForge_ServicesConnection
                  implements BuildForge_Strings_Localizer {

                    protected function createResponse() {
                        $this->mode = BUILDFORGE_SERVICES_MODE_READ;
                        $response = new BuildForge_Services_JSONResponse($this);
                        $response->attach($this);
                        return $response;
                    }

                    public function update(SplSubject $subject) {
                        $this->mode = BUILDFORGE_SERVICES_MODE_IDLE;
                    }
          }


    15.   Observer to Track State
          class BuildForge_Services_Response
                  extends BuildForge_Utilities_Observable {

                    public function __destruct() {
                        $this->readRemaining();
                        $this->notify();
                    }
          }

http://localhost/enterpriseguts/                                                         Page 5 of 6
Digging Through the Guts of Enterprise PHP                                                                                       9/19/08 10:58 AM




    16.   Other PHP-Specific Additions
          __toString() for all DBOs
          print $project;
          /* prints: Project[projectId=5bd405d70c3f1000d081238b009625ac, level=6, name=Project One, class=58BB01F0-836A-11DD-A3D4-
          8B1B7F9F254D, selectorId=5bd403da0c3f100086e8238b0043b5da, tag=BUILD_$B, envId=, active=1, snotify=0, pnotify=0, fnotify=0,
          maxThread=0, runLimit=0, tagSync=, sticky=, passChainId=, failChainId=, geoId=, isDefaultSnapshot=1, snapshotUuid=!Snapshot,
          snapshotSetUuid=5bd405d30c3f1000d080238b009625ac, parentUuid=, steps= <Step[stepUuid=5bd405de0c3f1000d082238b009625ac,
          projectId=5bd405d70c3f1000d081238b009625ac, stepId=1, envId=, filterId=, inlineChainId=, description=Step one, stepType=REGULAR,
          dir=/, passNotify=0, failNotify=0, onFail=HALT, selectorId=, threaded=NO, absolute=, timeout=300, maxIterations=100, level=0,
          broadcast=, commandText=echo quot;hiquot;, elseCommandText=, conditionText=, passChainId=, failChainId=, elseInlineId=, active=1, passWait=,
          failWait=]>] */




          __clone() for clone keyword support
          $projectTwo = clone $projectOne;
          $projectTwo->setName('Look, a new Project!');
          $projectTwo->create();


    17.   These make my life easier
                    Object-Oriented
                    Inheritance
                    Interfaces
                    Type hinting
                    Exceptions
                    Iterators


    18.   What I can't wait to use next
                    Namespaces
                    Unicode
                    Late Static Bindings
                    Closures
                    try { } catch { } finally { } (Please?)


    19.   Questions?


http://localhost/enterpriseguts/                                                                                                        Page 6 of 6

Contenu connexe

Plus de ZendCon

Framework Shootout
Framework ShootoutFramework Shootout
Framework ShootoutZendCon
 
Zend_Tool: Practical use and Extending
Zend_Tool: Practical use and ExtendingZend_Tool: Practical use and Extending
Zend_Tool: Practical use and ExtendingZendCon
 
PHP on IBM i Tutorial
PHP on IBM i TutorialPHP on IBM i Tutorial
PHP on IBM i TutorialZendCon
 
PHP on Windows - What's New
PHP on Windows - What's NewPHP on Windows - What's New
PHP on Windows - What's NewZendCon
 
PHP and Platform Independance in the Cloud
PHP and Platform Independance in the CloudPHP and Platform Independance in the Cloud
PHP and Platform Independance in the CloudZendCon
 
I18n with PHP 5.3
I18n with PHP 5.3I18n with PHP 5.3
I18n with PHP 5.3ZendCon
 
Cloud Computing: The Hard Problems Never Go Away
Cloud Computing: The Hard Problems Never Go AwayCloud Computing: The Hard Problems Never Go Away
Cloud Computing: The Hard Problems Never Go AwayZendCon
 
Planning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local DatabasesPlanning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local DatabasesZendCon
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework ApplicationZendCon
 
Enterprise-Class PHP Security
Enterprise-Class PHP SecurityEnterprise-Class PHP Security
Enterprise-Class PHP SecurityZendCon
 
PHP and IBM i - Database Alternatives
PHP and IBM i - Database AlternativesPHP and IBM i - Database Alternatives
PHP and IBM i - Database AlternativesZendCon
 
Zend Core on IBM i - Security Considerations
Zend Core on IBM i - Security ConsiderationsZend Core on IBM i - Security Considerations
Zend Core on IBM i - Security ConsiderationsZendCon
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingZendCon
 
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...ZendCon
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilityZendCon
 
Joe Staner Zend Con 2008
Joe Staner Zend Con 2008Joe Staner Zend Con 2008
Joe Staner Zend Con 2008ZendCon
 
Tiery Eyed
Tiery EyedTiery Eyed
Tiery EyedZendCon
 
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...ZendCon
 
DB2 Storage Engine for MySQL and Open Source Applications Session
DB2 Storage Engine for MySQL and Open Source Applications SessionDB2 Storage Engine for MySQL and Open Source Applications Session
DB2 Storage Engine for MySQL and Open Source Applications SessionZendCon
 
Digital Identity
Digital IdentityDigital Identity
Digital IdentityZendCon
 

Plus de ZendCon (20)

Framework Shootout
Framework ShootoutFramework Shootout
Framework Shootout
 
Zend_Tool: Practical use and Extending
Zend_Tool: Practical use and ExtendingZend_Tool: Practical use and Extending
Zend_Tool: Practical use and Extending
 
PHP on IBM i Tutorial
PHP on IBM i TutorialPHP on IBM i Tutorial
PHP on IBM i Tutorial
 
PHP on Windows - What's New
PHP on Windows - What's NewPHP on Windows - What's New
PHP on Windows - What's New
 
PHP and Platform Independance in the Cloud
PHP and Platform Independance in the CloudPHP and Platform Independance in the Cloud
PHP and Platform Independance in the Cloud
 
I18n with PHP 5.3
I18n with PHP 5.3I18n with PHP 5.3
I18n with PHP 5.3
 
Cloud Computing: The Hard Problems Never Go Away
Cloud Computing: The Hard Problems Never Go AwayCloud Computing: The Hard Problems Never Go Away
Cloud Computing: The Hard Problems Never Go Away
 
Planning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local DatabasesPlanning for Synchronization with Browser-Local Databases
Planning for Synchronization with Browser-Local Databases
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework Application
 
Enterprise-Class PHP Security
Enterprise-Class PHP SecurityEnterprise-Class PHP Security
Enterprise-Class PHP Security
 
PHP and IBM i - Database Alternatives
PHP and IBM i - Database AlternativesPHP and IBM i - Database Alternatives
PHP and IBM i - Database Alternatives
 
Zend Core on IBM i - Security Considerations
Zend Core on IBM i - Security ConsiderationsZend Core on IBM i - Security Considerations
Zend Core on IBM i - Security Considerations
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server Tracing
 
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...
Insights from the Experts: How PHP Leaders Are Transforming High-Impact PHP A...
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
 
Joe Staner Zend Con 2008
Joe Staner Zend Con 2008Joe Staner Zend Con 2008
Joe Staner Zend Con 2008
 
Tiery Eyed
Tiery EyedTiery Eyed
Tiery Eyed
 
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...
Make your PHP Application Software-as-a-Service (SaaS) Ready with the Paralle...
 
DB2 Storage Engine for MySQL and Open Source Applications Session
DB2 Storage Engine for MySQL and Open Source Applications SessionDB2 Storage Engine for MySQL and Open Source Applications Session
DB2 Storage Engine for MySQL and Open Source Applications Session
 
Digital Identity
Digital IdentityDigital Identity
Digital Identity
 

Dernier

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 

Dernier (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 

Digging Through The Guts Of Enterprise Php

  • 1. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM 1. Digging Through the Guts of Enterprise PHP A Case Study Shawn Lauriat IBM Rational Build Forge 2. Introductions Me Advisory Engineer, Lead UI/G11N Developer @ IBM Rational Build Forge Author, Advanced Ajax: Architectures and Best Practices http://frozen-o.com/blog/ Build Forge quot;It automates and accelerates build and release processes through server pooling and fault tolerance for Agile development and streamlined software delivery.quot; a.k.a. process automation tool 3. Disclaimer The views expressed in this commentary are the author's own and do not necessarily reflect those of IBM. 4. Overview I will not: Teach you to use PHP5 features I will: Show PHP5 features' usefulness Show PHP5 features in code Show PHP5 features in action 5. Interfaces http://localhost/enterpriseguts/ Page 1 of 6
  • 2. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM class -> Instance Definition interface -> Instance Requirements Definition interface + type hinting = more stable code with less effort 6. BuildForge_Services_Serializable /** Used for object transportation */ interface BuildForge_Services_Serializable { /** @param array|null $data */ public function fromArray(array $data = null); /** @return array */ public function toArray(); } 7. BuildForge_Services_DBO_Snapshottable /** Create snapshot metadata */ $snapshot = BuildForge_Services_DBO_Snapshot::createSnapshot( $services, quot;My New Snapshotquot;, quot;A Comment about My New Snapshotquot; ); /** Get a new snapshot of the $originalOne */ return $originalOne->snapshot( $snapshot->getUuid(), new BuildForge_Services_DBO_SnapshotRequest(true), false ); 8. Inheritance BuildForge_Services_DBO_Project http://localhost/enterpriseguts/ Page 2 of 6
  • 3. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM Fields Custom Methods implements BuildForge_Services_DBO_Snapshottable extends BuildForge_Services_UUIDDBO ::getUuid() ::isLive() extends BuildForge_Services_DBO implements BuildForge_Services_Serializable ::__construct() 9. Iterators interface Iterator extends Traversable { function rewind(); function current(); function key(); function next(); function valid(); } 10. Using Iterators for scalability The Class Tree Iterator OuterIterator BuildForge_Services_Iterator BuildForge_Services_ProjectIterator Iterator BuildForge_Services_ValueIterator 11. Using Iterators for Scalability The Code http://localhost/enterpriseguts/ Page 3 of 6
  • 4. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM class BuildForge_Services_DBO_ProjectIterator extends BuildForge_Services_Iterator { public function current() { $current = parent::current(); if (empty($current)) return $current; $project = new BuildForge_Services_DBO_Project($this->conn); $project->fromArray($current); return $project; } } // Elsewhere in the app... $projects = BuildForge_Services_DBO_Project::iterateAll($services); foreach ($projects as $project) { // Do stuff } 12. Design Patterns 13. Model-View-Controller Code class Projects { public function render() { $projects = BuildForge_Services_DBO_Project http://localhost/enterpriseguts/ Page 4 of 6
  • 5. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM ::iterateFiltered( $this->services, $filter ); $this->view->register_object('listing', $projects); } } <tbody id=quot;listingquot;> <?php try { foreach ($_['listing'] as $project_instance) { print '<tr>'; // etc. print '</tr>'; } } catch (Exception $e) { /* do something */ } ?> </tbody> 14. Observer to Track State class BuildForge_ServicesConnection implements BuildForge_Strings_Localizer { protected function createResponse() { $this->mode = BUILDFORGE_SERVICES_MODE_READ; $response = new BuildForge_Services_JSONResponse($this); $response->attach($this); return $response; } public function update(SplSubject $subject) { $this->mode = BUILDFORGE_SERVICES_MODE_IDLE; } } 15. Observer to Track State class BuildForge_Services_Response extends BuildForge_Utilities_Observable { public function __destruct() { $this->readRemaining(); $this->notify(); } } http://localhost/enterpriseguts/ Page 5 of 6
  • 6. Digging Through the Guts of Enterprise PHP 9/19/08 10:58 AM 16. Other PHP-Specific Additions __toString() for all DBOs print $project; /* prints: Project[projectId=5bd405d70c3f1000d081238b009625ac, level=6, name=Project One, class=58BB01F0-836A-11DD-A3D4- 8B1B7F9F254D, selectorId=5bd403da0c3f100086e8238b0043b5da, tag=BUILD_$B, envId=, active=1, snotify=0, pnotify=0, fnotify=0, maxThread=0, runLimit=0, tagSync=, sticky=, passChainId=, failChainId=, geoId=, isDefaultSnapshot=1, snapshotUuid=!Snapshot, snapshotSetUuid=5bd405d30c3f1000d080238b009625ac, parentUuid=, steps= <Step[stepUuid=5bd405de0c3f1000d082238b009625ac, projectId=5bd405d70c3f1000d081238b009625ac, stepId=1, envId=, filterId=, inlineChainId=, description=Step one, stepType=REGULAR, dir=/, passNotify=0, failNotify=0, onFail=HALT, selectorId=, threaded=NO, absolute=, timeout=300, maxIterations=100, level=0, broadcast=, commandText=echo quot;hiquot;, elseCommandText=, conditionText=, passChainId=, failChainId=, elseInlineId=, active=1, passWait=, failWait=]>] */ __clone() for clone keyword support $projectTwo = clone $projectOne; $projectTwo->setName('Look, a new Project!'); $projectTwo->create(); 17. These make my life easier Object-Oriented Inheritance Interfaces Type hinting Exceptions Iterators 18. What I can't wait to use next Namespaces Unicode Late Static Bindings Closures try { } catch { } finally { } (Please?) 19. Questions? http://localhost/enterpriseguts/ Page 6 of 6