SlideShare une entreprise Scribd logo
1  sur  63
Télécharger pour lire hors ligne
Alloy Framework
                            PHP 5.3+ Modular Hierarchical MVC
                            http://alloyframework.org




Wednesday, March 30, 2011
Who am I?
              Vance Lucas
                    http://vancelucas.com
                    @vlucas
                    Business: http://actridge.com
              PHP dev since 1999 (PHP 3)


              I love good OOP code and concepts, but hate the
              complexity it brings


   Vance Lucas (@vlucas)           http://alloyframework.org   2
Wednesday, March 30, 2011
A Few Points...
         Kind of a disclaimer, but not really




Wednesday, March 30, 2011
You May NOT Like Alloy If...
              You are an Object-Oriented Programming Purist
              You don’t care how complex code is as long as it’s
              “correct” OOP (because some guy’s book said so)
              You LOVE using Zend Framework, Symfony, or FLOW3
              You LOVE XML and Dependency Injection Containers
              You are looking for a component library




   Vance Lucas (@vlucas)        http://alloyframework.org    4
Wednesday, March 30, 2011
You MIGHT Like Alloy If...
              You think frameworks like Zend, Symfony, or FLOW3
              make some things too difficult and cumbersome
              You don’t think any PHP framework has it quite right
              You don’t like “too much magic”
              You want to know what your framework is doing
              You value ease of use over everything else
              You want good OOP code that follows known coding
              standards that is still easy to use and understand


   Vance Lucas (@vlucas)        http://alloyframework.org    5
Wednesday, March 30, 2011
Philosophy
              Usefulness, Simplicity and Strong Design
                    Minimum code, maximum impact
              Use OOP principles and design, but don’t over-do it
                    PHP is not Java with dollar signs
              Explicitness > “Magic”
                    Easier to understand & see what is going on
              Design patterns should never trump user experience or
              get in the way
              Users over “correctness”
   Vance Lucas (@vlucas)            http://alloyframework.org     6
Wednesday, March 30, 2011
Alloy Framework Goals
              Lightweight
              Modular Organization
              Hierarchical MVC (HMVC)
              Easy to understand and use
              Easy to make REST APIs and HTML pages
              No config/setup necessary, works anywhere
              Follow PEAR/Zend Coding Standards
              Strike a balance between good OOP concepts
              and ease of use with low learning curve
   Vance Lucas (@vlucas)      http://alloyframework.org   7
Wednesday, March 30, 2011
Alloy Architecture
         Inside & Out




Wednesday, March 30, 2011
Alloy Architecture Overview
              Modular Organization
              Kernel
              Plugins
              Hierarchical MVC (HMVC)
              Controllers as Resources
              Events and Filters




   Vance Lucas (@vlucas)           http://alloyframework.org   9
Wednesday, March 30, 2011
Modular Organization
                                      All related files in a single
                                      top-level named folder
                                      No separate “controllers”,
                                      “models” and “views”
                                      directories at same level
                                      Unlimited levels of nesting
                                      Easier distributable
                                      packages



   Vance Lucas (@vlucas)    http://alloyframework.org       10
Wednesday, March 30, 2011
Kernel

              Core object available from anywhere in your app
                    Kernel() - only global-scope function in Alloy
              Multiple uses:
                    Config access
                    Lazy-loading Factory / Service Locator
                    Extension Point for Modules and Plugins
                    Sole Dependency

   Vance Lucas (@vlucas)            http://alloyframework.org     11
Wednesday, March 30, 2011
Kernel - Config Access
              Getter




              Setter




   Vance Lucas (@vlucas)    http://alloyframework.org   12
Wednesday, March 30, 2011
Kernel - Lazy-Load Factory
              Write This:




              Not That:


              Or This:




   Vance Lucas (@vlucas)    http://alloyframework.org   13
Wednesday, March 30, 2011
Kernel - Extension Point

              Proxies to callbacks added at runtime via __call




              Enables all kinds of custom functionality
                    Factory methods for loading & using 3rd party libs
                    Exposing plugin methods for global use
                    Helper or utility methods

   Vance Lucas (@vlucas)            http://alloyframework.org    14
Wednesday, March 30, 2011
Plugins
         The primary way of extending Alloy




Wednesday, March 30, 2011
Plugin - Symfony2 Finder
              File: app/Plugin/Finder/Plugin.php
              Libs: app/Plugin/Finder/lib/Symfony/Component/ ...




              Add finder method to Kernel for use

   Vance Lucas (@vlucas)      http://alloyframework.org   16
Wednesday, March 30, 2011
Plugin - Add to Config
              File: app/config/app.php




   Vance Lucas (@vlucas)     http://alloyframework.org   17
Wednesday, March 30, 2011
Plugin - Usage
              Use finder method on Kernel instance




   Vance Lucas (@vlucas)      http://alloyframework.org   18
Wednesday, March 30, 2011
Hierarchical MVC
         Solves the “widget problem”




Wednesday, March 30, 2011
Hierarchical MVC
              Multiple MVC dispatches to fulfill a single request
              Solves the “widget problem”
                    Sidebar content can be self-contained module
                            Ads, tag clouds, blog headlines, etc.
                    Encourages module re-use & helps DRY
              Not strictly “hierarchical” - more like nested
                    Hierarchy is not tracked or enforced in any way



   Vance Lucas (@vlucas)                 http://alloyframework.org   20
Wednesday, March 30, 2011
Vance Lucas (@vlucas)    http://alloyframework.org   21
Wednesday, March 30, 2011
Vance Lucas (@vlucas)    http://alloyframework.org   22
Wednesday, March 30, 2011
Controllers
         Respond to both internal and external requests




Wednesday, March 30, 2011
Controllers
              Part of the Module package that handles requests
              Special name “scope” for web-accessible actions
                    GET = <action>Action
                    POST, PUT, DELETE, etc = <action>Method
                    Ensures HTTP methods are required for access
              AlloyRequest object is first parameter
              All named params from route set on Request object



   Vance Lucas (@vlucas)         http://alloyframework.org   24
Wednesday, March 30, 2011
Controllers (cont’d)
              NOTHING is automatically or implicitly loaded
                    No views, models, or anything else
              Explicitly return response or content to send
              Controllers are not factories
                    Controllers are extremely lightweight
              Controllers do not hold the context of their requests




   Vance Lucas (@vlucas)           http://alloyframework.org   25
Wednesday, March 30, 2011
Example REST Controller
              Notice <name>Action vs <name>Method




   Vance Lucas (@vlucas)    http://alloyframework.org   26
Wednesday, March 30, 2011
Controller Response Types
         Sending output and manipulating control flow




Wednesday, March 30, 2011
Simple Strings
              Sends 200 OK status with string content as body




   Vance Lucas (@vlucas)       http://alloyframework.org   28
Wednesday, March 30, 2011
Any object with __toString
              Sends 200 OK status with string content as body




   Vance Lucas (@vlucas)       http://alloyframework.org   29
Wednesday, March 30, 2011
View Templates
              Most common Module response type
              Returns object - template not yet rendered




   Vance Lucas (@vlucas)       http://alloyframework.org   30
Wednesday, March 30, 2011
Resource Objects
              Auto-converts array to JSON or XML for API response
              Accepts objects with toArray methods




   Vance Lucas (@vlucas)      http://alloyframework.org   31
Wednesday, March 30, 2011
Generic Response
              Body + HTTP Status
              Base AlloyModuleResponse that view templates and
              resources extend from
                    Can set custom layout, errors, headers, etc. using a
                    fluent interface just like templates and resources




   Vance Lucas (@vlucas)           http://alloyframework.org     32
Wednesday, March 30, 2011
Boolean False
              Generic 404 (Throws AlloyExceptionFileNotFound)
                    Plugins can filter on ‘dispatch_exception’ event to
                    produce a custom global response




   Vance Lucas (@vlucas)            http://alloyframework.org    33
Wednesday, March 30, 2011
Why Explicit Returns?
         Easier to manipulate responses and control flow




Wednesday, March 30, 2011
Easier to re-use Actions
              Re-use form template from ‘newAction’
              No forwarding or other indirection necessary
              Object return lets you modify it further before display
              through fluent interface




   Vance Lucas (@vlucas)         http://alloyframework.org     35
Wednesday, March 30, 2011
Modify Dispatches at Will
              Template object returned is not yet rendered so we
              can modify it at will
                    Change path to a local template
                    Change layout
                    Add errors
                    Change response code or headers, etc.
              Very flexible



   Vance Lucas (@vlucas)            http://alloyframework.org   36
Wednesday, March 30, 2011
... Even pull out values
              Since the template is not yet rendered, we can even
              pull out values that have been set and re-use them
              however we want to
              We don’t even have to render the dispatch result at all
                    No wasted resources




   Vance Lucas (@vlucas)          http://alloyframework.org   37
Wednesday, March 30, 2011
URL Routing
         Simple named parameters, full control




Wednesday, March 30, 2011
Parameter Types
              <:alpha>
                    Matches [a-zA-Z0-9_-+%s]+
              <#numeric>
                    Matches [0-9]+
              <*wildcard>
                    Marches .*


              Does NOT split the URL by “segment”

   Vance Lucas (@vlucas)             http://alloyframework.org   39
Wednesday, March 30, 2011
Some Default Routes
              Fluent interface allows route modification
              REST verb params will override defaults and matches
                    POST /module/add => Module::postMethod




   Vance Lucas (@vlucas)         http://alloyframework.org   40
Wednesday, March 30, 2011
Custom Routes
              Can be literally anything
                    URL does not have to map <controller>/<action>


              Example from Autoridge.com
                    /<#year>/<:make>/<:model>




   Vance Lucas (@vlucas)          http://alloyframework.org   41
Wednesday, March 30, 2011
Static Routes
              Map arbitrary static path to Module::action
              No PREG matching overhead
              Path can include slashes and be as long as necessary
                    Router does not split URL into segments




   Vance Lucas (@vlucas)           http://alloyframework.org   42
Wednesday, March 30, 2011
Making an App
         HTML + JSON API, single Controller method




Wednesday, March 30, 2011
app/Module/Blog/Post.php

              Using Spot ORM (Ships with Alloy, but NOT required)
              Spot provided with a plugin, not tied to Alloy in any way




   Vance Lucas (@vlucas)        http://alloyframework.org     44
Wednesday, March 30, 2011
Blog Example
              app/Module/Blog/Controller.php




   Vance Lucas (@vlucas)     http://alloyframework.org   45
Wednesday, March 30, 2011
app/Module/Blog/views/index.html.php




   Vance Lucas (@vlucas)    http://alloyframework.org   46
Wednesday, March 30, 2011
http://localhost/path/blog




   Vance Lucas (@vlucas)    http://alloyframework.org   47
Wednesday, March 30, 2011
Magic Datagrid?
              Alloy has View Generics
                    Extensions of view templates
                    Generic HTML template markup with custom
                    functions that accept Closures to enable fully
                    custom PHP markup in designated areas (like table
                    cells) with no special syntax or recursive includes
              You don’t have to use them, but they can be huge
              time-savers if you do




   Vance Lucas (@vlucas)           http://alloyframework.org     48
Wednesday, March 30, 2011
Adding an API
              Template for HTML, Resource object for API




   Vance Lucas (@vlucas)       http://alloyframework.org   49
Wednesday, March 30, 2011
http://localhost/path/blog/index.json

              Array -> JSON via Resource response type




   Vance Lucas (@vlucas)      http://alloyframework.org   50
Wednesday, March 30, 2011
API Errors?




   Vance Lucas (@vlucas)    http://alloyframework.org   51
Wednesday, March 30, 2011
HTML




                       JSON


   Vance Lucas (@vlucas)      http://alloyframework.org   52
Wednesday, March 30, 2011
Layouts & Blocks
         Make your App Look Nice




Wednesday, March 30, 2011
Layouts
              Really just another view template with a special location
              Includes both header & footer, content placed inside




   Vance Lucas (@vlucas)        http://alloyframework.org     54
Wednesday, March 30, 2011
Blocks
              Named regions that content can be pushed to from
              any view template in your app
              Static to current request so no data has to be passed




   Vance Lucas (@vlucas)       http://alloyframework.org    55
Wednesday, March 30, 2011
app/layouts/app.html.php




   Vance Lucas (@vlucas)    http://alloyframework.org   56
Wednesday, March 30, 2011
app/Module/Blog/views/viewAction.html.php

              Post tag list in layout sidebar




   Vance Lucas (@vlucas)         http://alloyframework.org   57
Wednesday, March 30, 2011
app/Module/Blog/views/viewAction.html.php




              HMVC dispatches as “widgetized” content
              Promotes better code re-use, DRY principle, allows
              polymorphic associations for generic types of content
   Vance Lucas (@vlucas)       http://alloyframework.org    58
Wednesday, March 30, 2011
Events & Filters
         Dynamic Behavior & Manipulating Responses




Wednesday, March 30, 2011
Layout Plugin
              Layout wrapping is achieved with a plugin in Alloy
                    Filters ‘dispatch_content’ event




   Vance Lucas (@vlucas)            http://alloyframework.org   60
Wednesday, March 30, 2011
Main Dispatch Content Filter




              Many other events and filters not shown in this diagram
   Vance Lucas (@vlucas)       http://alloyframework.org    61
Wednesday, March 30, 2011
Layout Plugin - wrapLayout
              Returns template wrapped in template




   Vance Lucas (@vlucas)       http://alloyframework.org   62
Wednesday, March 30, 2011
Thanks!
              Alloy on the web:
                    http://alloyframework.org
                    http://github.com/alloyphp


              Vance Lucas
                    Personal: http://vancelucas.com
                    Business: http://actridge.com



   Vance Lucas (@vlucas)           http://alloyframework.org   63
Wednesday, March 30, 2011

Contenu connexe

Similaire à Alloy HMVC PHP Framework

Apache Solr-Webinar
Apache Solr-WebinarApache Solr-Webinar
Apache Solr-WebinarEdureka!
 
Cross-Platform Mobile Development with Titanium
Cross-Platform Mobile Development with TitaniumCross-Platform Mobile Development with Titanium
Cross-Platform Mobile Development with TitaniumVance Lucas
 
Positioning Yourself for the Future
Positioning Yourself for the FuturePositioning Yourself for the Future
Positioning Yourself for the FutureScott Lowe
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrLucidworks (Archived)
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrLucidworks (Archived)
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrLucidworks (Archived)
 
An introduction to Storm Crawler
An introduction to Storm CrawlerAn introduction to Storm Crawler
An introduction to Storm CrawlerJulien Nioche
 
Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1YI-CHING WU
 
2010 E Learning Ft Worth
2010 E Learning Ft Worth2010 E Learning Ft Worth
2010 E Learning Ft WorthRhonda Ficek
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternsbonej010
 
Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsSathish Chittibabu
 
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 World
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 WorldOmeka: Cost-Effective Web Publishing for Museums in a Web 2.0 World
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 WorldSharon Leon
 
ApacheCon NA 2011 report
ApacheCon NA 2011 reportApacheCon NA 2011 report
ApacheCon NA 2011 reportKoji Kawamura
 
LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?Arnaud Héritier
 
PL/SQL Interview Questions
PL/SQL Interview QuestionsPL/SQL Interview Questions
PL/SQL Interview QuestionsSrinimf-Slides
 
Linq to xml
Linq to xmlLinq to xml
Linq to xmlMickey
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphonyBrahampal Singh
 
Customising Oracle's eBusiness Suite
Customising Oracle's eBusiness SuiteCustomising Oracle's eBusiness Suite
Customising Oracle's eBusiness Suitedrdavidtaylor
 

Similaire à Alloy HMVC PHP Framework (20)

Apache Solr-Webinar
Apache Solr-WebinarApache Solr-Webinar
Apache Solr-Webinar
 
Cross-Platform Mobile Development with Titanium
Cross-Platform Mobile Development with TitaniumCross-Platform Mobile Development with Titanium
Cross-Platform Mobile Development with Titanium
 
Mocking the unmockable with Moles
Mocking the unmockable with MolesMocking the unmockable with Moles
Mocking the unmockable with Moles
 
Positioning Yourself for the Future
Positioning Yourself for the FuturePositioning Yourself for the Future
Positioning Yourself for the Future
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with Solr
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with Solr
 
Indexing Text and HTML Files with Solr
Indexing Text and HTML Files with SolrIndexing Text and HTML Files with Solr
Indexing Text and HTML Files with Solr
 
An introduction to Storm Crawler
An introduction to Storm CrawlerAn introduction to Storm Crawler
An introduction to Storm Crawler
 
Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1Introduction to Lucene and Solr - 1
Introduction to Lucene and Solr - 1
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
2010 E Learning Ft Worth
2010 E Learning Ft Worth2010 E Learning Ft Worth
2010 E Learning Ft Worth
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring tools
 
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 World
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 WorldOmeka: Cost-Effective Web Publishing for Museums in a Web 2.0 World
Omeka: Cost-Effective Web Publishing for Museums in a Web 2.0 World
 
ApacheCon NA 2011 report
ApacheCon NA 2011 reportApacheCon NA 2011 report
ApacheCon NA 2011 report
 
LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?LyonJUG - Maven 3.x, will it live up to its promises?
LyonJUG - Maven 3.x, will it live up to its promises?
 
PL/SQL Interview Questions
PL/SQL Interview QuestionsPL/SQL Interview Questions
PL/SQL Interview Questions
 
Linq to xml
Linq to xmlLinq to xml
Linq to xml
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
 
Customising Oracle's eBusiness Suite
Customising Oracle's eBusiness SuiteCustomising Oracle's eBusiness Suite
Customising Oracle's eBusiness Suite
 

Plus de Vance Lucas

How to Evaluate Your App Idea
How to Evaluate Your App IdeaHow to Evaluate Your App Idea
How to Evaluate Your App IdeaVance Lucas
 
How to Build a Tech Community
How to Build a Tech CommunityHow to Build a Tech Community
How to Build a Tech CommunityVance Lucas
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkVance Lucas
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementVance Lucas
 
Object Oriented Apologetics
Object Oriented ApologeticsObject Oriented Apologetics
Object Oriented ApologeticsVance Lucas
 
PHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedPHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedVance Lucas
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5Vance Lucas
 

Plus de Vance Lucas (7)

How to Evaluate Your App Idea
How to Evaluate Your App IdeaHow to Evaluate Your App Idea
How to Evaluate Your App Idea
 
How to Build a Tech Community
How to Build a Tech CommunityHow to Build a Tech Community
How to Build a Tech Community
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Stackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content ManagementStackbox CMS: Next-Generation Content Management
Stackbox CMS: Next-Generation Content Management
 
Object Oriented Apologetics
Object Oriented ApologeticsObject Oriented Apologetics
Object Oriented Apologetics
 
PHP - Procedural To Object-Oriented
PHP - Procedural To Object-OrientedPHP - Procedural To Object-Oriented
PHP - Procedural To Object-Oriented
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5
 

Dernier

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
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.
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Alloy HMVC PHP Framework

  • 1. Alloy Framework PHP 5.3+ Modular Hierarchical MVC http://alloyframework.org Wednesday, March 30, 2011
  • 2. Who am I? Vance Lucas http://vancelucas.com @vlucas Business: http://actridge.com PHP dev since 1999 (PHP 3) I love good OOP code and concepts, but hate the complexity it brings Vance Lucas (@vlucas) http://alloyframework.org 2 Wednesday, March 30, 2011
  • 3. A Few Points... Kind of a disclaimer, but not really Wednesday, March 30, 2011
  • 4. You May NOT Like Alloy If... You are an Object-Oriented Programming Purist You don’t care how complex code is as long as it’s “correct” OOP (because some guy’s book said so) You LOVE using Zend Framework, Symfony, or FLOW3 You LOVE XML and Dependency Injection Containers You are looking for a component library Vance Lucas (@vlucas) http://alloyframework.org 4 Wednesday, March 30, 2011
  • 5. You MIGHT Like Alloy If... You think frameworks like Zend, Symfony, or FLOW3 make some things too difficult and cumbersome You don’t think any PHP framework has it quite right You don’t like “too much magic” You want to know what your framework is doing You value ease of use over everything else You want good OOP code that follows known coding standards that is still easy to use and understand Vance Lucas (@vlucas) http://alloyframework.org 5 Wednesday, March 30, 2011
  • 6. Philosophy Usefulness, Simplicity and Strong Design Minimum code, maximum impact Use OOP principles and design, but don’t over-do it PHP is not Java with dollar signs Explicitness > “Magic” Easier to understand & see what is going on Design patterns should never trump user experience or get in the way Users over “correctness” Vance Lucas (@vlucas) http://alloyframework.org 6 Wednesday, March 30, 2011
  • 7. Alloy Framework Goals Lightweight Modular Organization Hierarchical MVC (HMVC) Easy to understand and use Easy to make REST APIs and HTML pages No config/setup necessary, works anywhere Follow PEAR/Zend Coding Standards Strike a balance between good OOP concepts and ease of use with low learning curve Vance Lucas (@vlucas) http://alloyframework.org 7 Wednesday, March 30, 2011
  • 8. Alloy Architecture Inside & Out Wednesday, March 30, 2011
  • 9. Alloy Architecture Overview Modular Organization Kernel Plugins Hierarchical MVC (HMVC) Controllers as Resources Events and Filters Vance Lucas (@vlucas) http://alloyframework.org 9 Wednesday, March 30, 2011
  • 10. Modular Organization All related files in a single top-level named folder No separate “controllers”, “models” and “views” directories at same level Unlimited levels of nesting Easier distributable packages Vance Lucas (@vlucas) http://alloyframework.org 10 Wednesday, March 30, 2011
  • 11. Kernel Core object available from anywhere in your app Kernel() - only global-scope function in Alloy Multiple uses: Config access Lazy-loading Factory / Service Locator Extension Point for Modules and Plugins Sole Dependency Vance Lucas (@vlucas) http://alloyframework.org 11 Wednesday, March 30, 2011
  • 12. Kernel - Config Access Getter Setter Vance Lucas (@vlucas) http://alloyframework.org 12 Wednesday, March 30, 2011
  • 13. Kernel - Lazy-Load Factory Write This: Not That: Or This: Vance Lucas (@vlucas) http://alloyframework.org 13 Wednesday, March 30, 2011
  • 14. Kernel - Extension Point Proxies to callbacks added at runtime via __call Enables all kinds of custom functionality Factory methods for loading & using 3rd party libs Exposing plugin methods for global use Helper or utility methods Vance Lucas (@vlucas) http://alloyframework.org 14 Wednesday, March 30, 2011
  • 15. Plugins The primary way of extending Alloy Wednesday, March 30, 2011
  • 16. Plugin - Symfony2 Finder File: app/Plugin/Finder/Plugin.php Libs: app/Plugin/Finder/lib/Symfony/Component/ ... Add finder method to Kernel for use Vance Lucas (@vlucas) http://alloyframework.org 16 Wednesday, March 30, 2011
  • 17. Plugin - Add to Config File: app/config/app.php Vance Lucas (@vlucas) http://alloyframework.org 17 Wednesday, March 30, 2011
  • 18. Plugin - Usage Use finder method on Kernel instance Vance Lucas (@vlucas) http://alloyframework.org 18 Wednesday, March 30, 2011
  • 19. Hierarchical MVC Solves the “widget problem” Wednesday, March 30, 2011
  • 20. Hierarchical MVC Multiple MVC dispatches to fulfill a single request Solves the “widget problem” Sidebar content can be self-contained module Ads, tag clouds, blog headlines, etc. Encourages module re-use & helps DRY Not strictly “hierarchical” - more like nested Hierarchy is not tracked or enforced in any way Vance Lucas (@vlucas) http://alloyframework.org 20 Wednesday, March 30, 2011
  • 21. Vance Lucas (@vlucas) http://alloyframework.org 21 Wednesday, March 30, 2011
  • 22. Vance Lucas (@vlucas) http://alloyframework.org 22 Wednesday, March 30, 2011
  • 23. Controllers Respond to both internal and external requests Wednesday, March 30, 2011
  • 24. Controllers Part of the Module package that handles requests Special name “scope” for web-accessible actions GET = <action>Action POST, PUT, DELETE, etc = <action>Method Ensures HTTP methods are required for access AlloyRequest object is first parameter All named params from route set on Request object Vance Lucas (@vlucas) http://alloyframework.org 24 Wednesday, March 30, 2011
  • 25. Controllers (cont’d) NOTHING is automatically or implicitly loaded No views, models, or anything else Explicitly return response or content to send Controllers are not factories Controllers are extremely lightweight Controllers do not hold the context of their requests Vance Lucas (@vlucas) http://alloyframework.org 25 Wednesday, March 30, 2011
  • 26. Example REST Controller Notice <name>Action vs <name>Method Vance Lucas (@vlucas) http://alloyframework.org 26 Wednesday, March 30, 2011
  • 27. Controller Response Types Sending output and manipulating control flow Wednesday, March 30, 2011
  • 28. Simple Strings Sends 200 OK status with string content as body Vance Lucas (@vlucas) http://alloyframework.org 28 Wednesday, March 30, 2011
  • 29. Any object with __toString Sends 200 OK status with string content as body Vance Lucas (@vlucas) http://alloyframework.org 29 Wednesday, March 30, 2011
  • 30. View Templates Most common Module response type Returns object - template not yet rendered Vance Lucas (@vlucas) http://alloyframework.org 30 Wednesday, March 30, 2011
  • 31. Resource Objects Auto-converts array to JSON or XML for API response Accepts objects with toArray methods Vance Lucas (@vlucas) http://alloyframework.org 31 Wednesday, March 30, 2011
  • 32. Generic Response Body + HTTP Status Base AlloyModuleResponse that view templates and resources extend from Can set custom layout, errors, headers, etc. using a fluent interface just like templates and resources Vance Lucas (@vlucas) http://alloyframework.org 32 Wednesday, March 30, 2011
  • 33. Boolean False Generic 404 (Throws AlloyExceptionFileNotFound) Plugins can filter on ‘dispatch_exception’ event to produce a custom global response Vance Lucas (@vlucas) http://alloyframework.org 33 Wednesday, March 30, 2011
  • 34. Why Explicit Returns? Easier to manipulate responses and control flow Wednesday, March 30, 2011
  • 35. Easier to re-use Actions Re-use form template from ‘newAction’ No forwarding or other indirection necessary Object return lets you modify it further before display through fluent interface Vance Lucas (@vlucas) http://alloyframework.org 35 Wednesday, March 30, 2011
  • 36. Modify Dispatches at Will Template object returned is not yet rendered so we can modify it at will Change path to a local template Change layout Add errors Change response code or headers, etc. Very flexible Vance Lucas (@vlucas) http://alloyframework.org 36 Wednesday, March 30, 2011
  • 37. ... Even pull out values Since the template is not yet rendered, we can even pull out values that have been set and re-use them however we want to We don’t even have to render the dispatch result at all No wasted resources Vance Lucas (@vlucas) http://alloyframework.org 37 Wednesday, March 30, 2011
  • 38. URL Routing Simple named parameters, full control Wednesday, March 30, 2011
  • 39. Parameter Types <:alpha> Matches [a-zA-Z0-9_-+%s]+ <#numeric> Matches [0-9]+ <*wildcard> Marches .* Does NOT split the URL by “segment” Vance Lucas (@vlucas) http://alloyframework.org 39 Wednesday, March 30, 2011
  • 40. Some Default Routes Fluent interface allows route modification REST verb params will override defaults and matches POST /module/add => Module::postMethod Vance Lucas (@vlucas) http://alloyframework.org 40 Wednesday, March 30, 2011
  • 41. Custom Routes Can be literally anything URL does not have to map <controller>/<action> Example from Autoridge.com /<#year>/<:make>/<:model> Vance Lucas (@vlucas) http://alloyframework.org 41 Wednesday, March 30, 2011
  • 42. Static Routes Map arbitrary static path to Module::action No PREG matching overhead Path can include slashes and be as long as necessary Router does not split URL into segments Vance Lucas (@vlucas) http://alloyframework.org 42 Wednesday, March 30, 2011
  • 43. Making an App HTML + JSON API, single Controller method Wednesday, March 30, 2011
  • 44. app/Module/Blog/Post.php Using Spot ORM (Ships with Alloy, but NOT required) Spot provided with a plugin, not tied to Alloy in any way Vance Lucas (@vlucas) http://alloyframework.org 44 Wednesday, March 30, 2011
  • 45. Blog Example app/Module/Blog/Controller.php Vance Lucas (@vlucas) http://alloyframework.org 45 Wednesday, March 30, 2011
  • 46. app/Module/Blog/views/index.html.php Vance Lucas (@vlucas) http://alloyframework.org 46 Wednesday, March 30, 2011
  • 47. http://localhost/path/blog Vance Lucas (@vlucas) http://alloyframework.org 47 Wednesday, March 30, 2011
  • 48. Magic Datagrid? Alloy has View Generics Extensions of view templates Generic HTML template markup with custom functions that accept Closures to enable fully custom PHP markup in designated areas (like table cells) with no special syntax or recursive includes You don’t have to use them, but they can be huge time-savers if you do Vance Lucas (@vlucas) http://alloyframework.org 48 Wednesday, March 30, 2011
  • 49. Adding an API Template for HTML, Resource object for API Vance Lucas (@vlucas) http://alloyframework.org 49 Wednesday, March 30, 2011
  • 50. http://localhost/path/blog/index.json Array -> JSON via Resource response type Vance Lucas (@vlucas) http://alloyframework.org 50 Wednesday, March 30, 2011
  • 51. API Errors? Vance Lucas (@vlucas) http://alloyframework.org 51 Wednesday, March 30, 2011
  • 52. HTML JSON Vance Lucas (@vlucas) http://alloyframework.org 52 Wednesday, March 30, 2011
  • 53. Layouts & Blocks Make your App Look Nice Wednesday, March 30, 2011
  • 54. Layouts Really just another view template with a special location Includes both header & footer, content placed inside Vance Lucas (@vlucas) http://alloyframework.org 54 Wednesday, March 30, 2011
  • 55. Blocks Named regions that content can be pushed to from any view template in your app Static to current request so no data has to be passed Vance Lucas (@vlucas) http://alloyframework.org 55 Wednesday, March 30, 2011
  • 56. app/layouts/app.html.php Vance Lucas (@vlucas) http://alloyframework.org 56 Wednesday, March 30, 2011
  • 57. app/Module/Blog/views/viewAction.html.php Post tag list in layout sidebar Vance Lucas (@vlucas) http://alloyframework.org 57 Wednesday, March 30, 2011
  • 58. app/Module/Blog/views/viewAction.html.php HMVC dispatches as “widgetized” content Promotes better code re-use, DRY principle, allows polymorphic associations for generic types of content Vance Lucas (@vlucas) http://alloyframework.org 58 Wednesday, March 30, 2011
  • 59. Events & Filters Dynamic Behavior & Manipulating Responses Wednesday, March 30, 2011
  • 60. Layout Plugin Layout wrapping is achieved with a plugin in Alloy Filters ‘dispatch_content’ event Vance Lucas (@vlucas) http://alloyframework.org 60 Wednesday, March 30, 2011
  • 61. Main Dispatch Content Filter Many other events and filters not shown in this diagram Vance Lucas (@vlucas) http://alloyframework.org 61 Wednesday, March 30, 2011
  • 62. Layout Plugin - wrapLayout Returns template wrapped in template Vance Lucas (@vlucas) http://alloyframework.org 62 Wednesday, March 30, 2011
  • 63. Thanks! Alloy on the web: http://alloyframework.org http://github.com/alloyphp Vance Lucas Personal: http://vancelucas.com Business: http://actridge.com Vance Lucas (@vlucas) http://alloyframework.org 63 Wednesday, March 30, 2011

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n