Digging Through The Guts Of Enterprise Php

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Digging Through The Guts Of Enterprise Php - Presentation Transcript

    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 \"It automates and accelerates build and release processes through server pooling and fault tolerance for Agile development and streamlined software delivery.\" 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, \"My New Snapshot\", \"A Comment about My New Snapshot\" ); /** 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=\"listing\"> <?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 \"hi\", 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

    + ZendConZendCon, 2 years ago

    custom

    1083 views, 1 favs, 0 embeds more stats

    BM Rational Build Forge started out as a small star more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1083
      • 1083 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 63
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags