SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Organizing Your
 PHP Projects
     Paul M. Jones
   ConFoo, Montréal
     10 Mar 2010

   http://joind.in/1289
Read These
• “Mythical Man-Month”, Brooks
• “Art of Project Management”, Berkun
• “Peopleware”, DeMarco and Lister




                    2
Project Planning
        in One Lesson
•   Examine real-world projects

•   The One Lesson for
    organizing your project

•   Elements of The One Lesson

•   The One Lesson in practice




                              3
About Me
•   Web Architect

•   PHP since 1999 (PHP 3)

•   Solar Framework (lead)

•   Savant Template System (lead)

•   Zend Framework (found. contrib.)

•   PEAR Group (2007-2008)

•   Web framework benchmarks

                                    4
About You
•   Project lead/manager?

•   Improve team consistency?

•   Want to share your code
    with others?

•   Want to use code from
    others?

•   Want to reduce recurring
    integration issues?

                                5
Goals for Organizing
•   Security

•   Integration and extension

•   Adaptable to change

•   Predictable and maintainable

•   Teamwork consistency

•   Re-use rules on multiple projects


                                    6
Project Research;
              or,
“Step 1: Study Underpinnings”



              7
Project Evolution Tracks
               One-Off
                Heap

              Standalone
                 App

  Library         ?
                           Modular App
 Collection

 Framework                    CMS

                  8
One-Off Heap
•   No discernible architecture

•   Browse directly to the scripts

•   Add to it piece by piece

•   Little to no separation of concerns

•   All variables are global

•   Unmanageable, difficult to extend


                                       9
Standalone Application
•   One-off heap ++

•   Series of separate page
    scripts and common includes

•   Installed in web root

•   Each responsible for global
    execution environment

•   Script variables still global


                                    10
Standalone Application:
   Typical Main Script
// Setup or bootstrapping
define('INCLUDE_PATH', dirname(__FILE__) . '/');
include_once INCLUDE_PATH . "inc/prepend.inc.php"
include_once INCLUDE_PATH . "lib/foo.class.php";
include_once INCLUDE_PATH . "lib/View.class.php";

// Actions (if we're lucky)
$foo = new Foo();
$data = $foo->getData();

// Display (if we're lucky)
$view = new View(INCLUDE_PATH . 'tpl/');
$view->assign($data);
echo $view->fetch('template.tpl');

// Teardown
include_once INCLUDE_PATH . "inc/append.inc.php";

                              11
Standalone Application:
  Typical Include File

// expects certain globals
if (! defined('APP_CONSTANT')) {
    die("Direct access not allowed.");
}




                   12
Standalone Application:
 Typical File Structure
 index.php               #   main pages
 page1.php               #
 page2.php               #
 page3.php               #
 sub/                    #   sub-section
      index.php          #
      zim.php            #
      gir.php            #
 inc/                    #   includes
      config.inc.php     #
      prepend.inc.php    #
 lib/                    #   libraries
      foo.class.php      #
      Bundle1/           #
      Bundle2/           #

                        13
Standalone Application:
   Support Structure
 bin/           #   command-line tools
 cache/         #   cache files
 css/           #   stylesheets
 docs/          #   documentation
 img/           #   images
 install/       #   installation scripts
 js/            #   javascript
 log/           #   log files
 sql/           #   schema migrations
 theme/         #   themes or skins
 tpl/           #   templates

 -- no standard naming or structure
 -- index.html file in each directory

                        14
Project Evolution Tracks
               One-Off
                Heap

              Standalone
                 App

  Library         ?
                           Modular App
 Collection

 Framework                    CMS

                  15
Modular Application
•   Standalone application ++

•   Same file structure and script style

•   One additional directory:
    “modules”, “plugins”, etc

•   Hooks in the “main” scripts for
    additional behaviors

•   Use global variables to coordinate
    between modules
                                16
CMS
•   Modular application ++

•   General-purpose application
    broker

•   All "main" scripts become
    sub-applications

•   Still in the web root, still
    using globals to coordinate



                                17
Application/CMS
             Projects
• Achievo         • Eventum     • PhpMyAdmin
• Code Igniter*   • Gallery     • Seagull*
• Coppermine      • Joomla/     • SugarCRM
                   Mambo
• DokuWiki                      • Vanilla
                  • MediaWiki
• Drupal                        • WordPress
                       18
Project Evolution Tracks
               One-Off
                Heap

              Standalone
                 App

  Library         ?
                           Modular App
 Collection

 Framework                    CMS

                  19
Library Collection
•   Specific, limited logic extracted
    from an app

•   Re-used directly in unrelated
    applications and other libraries

•   No global variables

•   Class-oriented

•   Can exist anywhere in the file
    system
                                       20
Library Project:
    Typical File Structure
Foo.php                 #    Foo
Foo/                    #
     Component.php      #    Foo_Component
     Component/         #
         Element1.php   #    Foo_Component_Element1
         Element2.php   #    Foo_Component_Element2
Bar.php                 #    Bar
Bar/                    #
     Task.php           #    Bar_Task
     Part/              #
         Part1.php      #    Bar_Task_Part1
         Part2.php      #    Bar_Task_Part2

                        21
Framework
•   Codebase

    •   Library collection

    •   Apps extend from it

•   Support structure

    •   Bootstrap file

    •   Public assets

    •   Protected assets

                              22
Library/Framework Projects
•   AdoDB            •   Lithium        •   Savant

•   Cake             •   Mojavi/Agavi   •   Seagull *

•   CgiApp           •   PAT            •   Smarty

•   Code Igniter *   •   PEAR           •   Solar

•   Doctrine         •   PHP Unit       •   SwiftMailer

•   EZ Components    •   Phing          •   Symfony

•   HtmlPurifier      •   Phly           •   WACT

•   Horde            •   Prado          •   Zend Framework

                                 23
Project Evolution Tracks
  class-       One-Off      include-
 oriented       Heap        oriented

              Standalone
                 App

  Library         ?
                           Modular App
 Collection

 Framework                    CMS

                  24
The One Lesson;
       or,
  “Step 2: ... ?”




        25
Organize your project
            as if
it is a library collection.
Elements of
        The One Lesson

• Stop using globals
• Namespace everything
• Class-to-file naming

                    27
1. Stop Using Globals

• Stop using
  register_globals

• Stop using $GLOBALS
• Stop using global

                        28
2. Namespace Everything

•   Automatic deconfliction of identifiers

    •   Classes (“vendor”)

    •   Functions, variables, constants

    •   Use with $_SESSION,
        $_COOKIE, etc. keys




                                    29
Choosing a Namespace

•   Project, client, brand, channel

•   A short word or acronym,
    not a letter (“Z”)

•   A unique name, not a generic
    name related to a task
    (Date, HTML, RSS, Table, User)




                                      30
PHP 5.2 “Namespaces”
// class User {}
class Vendor_User {}
$user = new Vendor_User();

// function get_info() {}
function vendor_get_info()

// $_SESSION["user_prefs"]
$_SESSION["Vendor_User"]["prefs"];
                31
PHP 5.3 Namespaces
namespace vendor;
class User {}

// relative namespace
namespace vendor;
$user = new User();

// absolute namespace
namespace other;
$user = new vendorUser();
                    32
3. Class-To-File Naming

• Class name maps directly to file name
 • Vendor_User    => Vendor/User.php

• Horde, PEAR, Solar, Zend, others
• Highly predictable file locations
• Lends itself to autoloading
                     33
Class-to-File Naming
 (PHP 5.2, Horde/PEAR)

// studly-caps needs preg_replace(), but:
VendorAuthOpenId => ...
    Vendor/Auth/Open/Id.php?
    Vendor/Auth/OpenId.php?

// underscores just need str_replace()
Vendor_Auth_OpenId => Vendor/Auth/OpenId.php




                      34
Class-to-File
          (PHP 5.3, PSR-0)

foo_barpkgMain     => /foo_bar/pkg/Main.php
foo_barpkgMain_Sub => /foo_bar/pkg/Main/Sub.php




      •   PEAR, Solar, Zend, Doctrine,
          Lithium, Symfony 2
                        35
The One Lesson In Practice;
           or,
     “Step 3: Profit!”




             36
Extended Effects of
             The One Lesson
•   Can be used anywhere
    (app, module, lib, CMS, framework)

•   Structure for refactoring and additions

•   Testing, profiling, and public files can
    parallel the same structure

•   Intuitive for new developers

•   No more include-path woes

                                      37
Mambo CMS
administrator/
components/
editor/
files/
help/
images/
includes/
    Vendor/
index.php
installation/
language/
mainbody.php
mambots/
media/
modules/
templates/
            38
Zend Framework
 project/
     application/
          bootstrap.php
          configs/
          controllers/
          models/
          views/
              helpers/
              scripts/
     library/
          Zend/
          Vendor/
     public
          index.php

              39
Lithium
app/
    config/
    controllers/
    extensions/
    index.php
    libraries/
    models/
    resources/
    tests/
    views/
    webroot/
libraries/
    lithium/
    vendor/

            40
Symfony 2
hello/
     config/
     console/
     HelloKernel.php
src/
     Application/
         HelloBundle/
              Bundle.php
              Controller/
              Resources/
     autoload.php
     vendor/
         symfony/
         zend/
         vendor/
web/
             41
Solar
system/
    config/
    config.php
    docroot/
         index.php
         public/
    include/
         Solar.php
         Solar/
         Vendor/
    script/
    source/
    sqlite/
    tmp/

             42
Solar Apps Are Libraries Too
          include/
            Solar/
            Vendor/
              App/
                Page.php
                Page/
                   Layout/
                   Locale/
                   Public/
                   View/
              Model/
                Gir.php
                Gir/
              Zim.php
              Zim/
                 43
Refactoring
• Move from existing include-based architecture
  to class-based architecture ...
  • ... by functionality
  • ... by script
• Then build scripts out of classes, not includes
• Then build apps out of classes, not scripts
• Leads to MVC / MVP / PAC architecture
                           44
Summary
The One Lesson

• Organize your project as if it will be part of
  a library collection
  • Avoid globals
  • Use namespaces for deconfliction
  • Use class-to-file naming convention

                         46
Goals for Organizing
•   Security

•   Integration and extension

•   Adaptable to change

•   Predictable and maintainable

•   Teamwork consistency

•   Re-use rules on multiple projects


                                   47
• Questions?
• Comments?
• Criticism?


               48
Thanks!

• <http://paul-m-jones.com>
• <http://solarphp.com>
• Solar Framework talk on Thursday
• <http://joind.in/1289>

                    49
Organizing Your PHP Projects (2010 ConFoo)

Mais conteúdo relacionado

Mais procurados

Best Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentBest Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentShahar Evron
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsAdam Culp
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend FrameworkAdam Culp
 
Web development with Python
Web development with PythonWeb development with Python
Web development with PythonRaman Balyan
 
Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing DevelopmentAdam Culp
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsPantheon
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 
Containerizing legacy applications
Containerizing legacy applicationsContainerizing legacy applications
Containerizing legacy applicationsAndrew Kirkpatrick
 
Behaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sBehaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sAndrew Kirkpatrick
 
WordPress Under Control (Boston WP Meetup)
WordPress Under Control (Boston WP Meetup)WordPress Under Control (Boston WP Meetup)
WordPress Under Control (Boston WP Meetup)Matt Bernhardt
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentkaspergarnaes
 
Introduction to GoLang
Introduction to GoLangIntroduction to GoLang
Introduction to GoLangNVISIA
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressiveMilad Arabi
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Pantheon
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLIJacques Woodcock
 
PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!Thomas Lee
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CIRan Bar-Zik
 
Using Zend Framework 2 Book Presentation
Using Zend Framework 2 Book PresentationUsing Zend Framework 2 Book Presentation
Using Zend Framework 2 Book Presentationolegkrivtsov
 

Mais procurados (20)

Best Practices in PHP Application Deployment
Best Practices in PHP Application DeploymentBest Practices in PHP Application Deployment
Best Practices in PHP Application Deployment
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Foundations of Zend Framework
Foundations of Zend FrameworkFoundations of Zend Framework
Foundations of Zend Framework
 
Web development with Python
Web development with PythonWeb development with Python
Web development with Python
 
Virtualizing Development
Virtualizing DevelopmentVirtualizing Development
Virtualizing Development
 
Phalcon overview
Phalcon overviewPhalcon overview
Phalcon overview
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 
Containerizing legacy applications
Containerizing legacy applicationsContainerizing legacy applications
Containerizing legacy applications
 
Behaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sBehaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’s
 
WordPress Under Control (Boston WP Meetup)
WordPress Under Control (Boston WP Meetup)WordPress Under Control (Boston WP Meetup)
WordPress Under Control (Boston WP Meetup)
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal development
 
Introduction to GoLang
Introduction to GoLangIntroduction to GoLang
Introduction to GoLang
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!PowerShell 101 - What is it and Why should YOU Care!
PowerShell 101 - What is it and Why should YOU Care!
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
 
Using Zend Framework 2 Book Presentation
Using Zend Framework 2 Book PresentationUsing Zend Framework 2 Book Presentation
Using Zend Framework 2 Book Presentation
 

Destaque

An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackVic Metcalfe
 
Namespaces and Autoloading
Namespaces and AutoloadingNamespaces and Autoloading
Namespaces and AutoloadingVic Metcalfe
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutVic Metcalfe
 

Destaque (6)

New in php 7
New in php 7New in php 7
New in php 7
 
An Elephant of a Different Colour: Hack
An Elephant of a Different Colour: HackAn Elephant of a Different Colour: Hack
An Elephant of a Different Colour: Hack
 
Namespaces and Autoloading
Namespaces and AutoloadingNamespaces and Autoloading
Namespaces and Autoloading
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Getting hands dirty with php7
Getting hands dirty with php7Getting hands dirty with php7
Getting hands dirty with php7
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 

Semelhante a Organizing Your PHP Projects (2010 ConFoo)

Extending ZF & Extending With ZF
Extending ZF & Extending With ZFExtending ZF & Extending With ZF
Extending ZF & Extending With ZFRalph Schindler
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Max Romanovsky
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovskyphp-user-group-minsk
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanityCharlie Morris
 
Phase2 Large Drupal Multisites (gta case study)
Phase2   Large Drupal Multisites (gta case study)Phase2   Large Drupal Multisites (gta case study)
Phase2 Large Drupal Multisites (gta case study)Phase2
 
One drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp CaceresOne drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp Cacereshernanibf
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutionsSangjin Lee
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentationArnaud Héritier
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayTony Ng
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiMichele Orselli
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiManuel Baldassarri
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module DevelopementMatt Mendonca
 
SD PHP Zend Framework
SD PHP Zend FrameworkSD PHP Zend Framework
SD PHP Zend Frameworkphilipjting
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Anil Sagar
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp Londonhernanibf
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studypeter_ibuildings
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframeworkhazzaz
 

Semelhante a Organizing Your PHP Projects (2010 ConFoo) (20)

Extending ZF & Extending With ZF
Extending ZF & Extending With ZFExtending ZF & Extending With ZF
Extending ZF & Extending With ZF
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanity
 
Zend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJSZend Framework MVC driven ExtJS
Zend Framework MVC driven ExtJS
 
Phase2 Large Drupal Multisites (gta case study)
Phase2   Large Drupal Multisites (gta case study)Phase2   Large Drupal Multisites (gta case study)
Phase2 Large Drupal Multisites (gta case study)
 
One drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp CaceresOne drupal to rule them all - Drupalcamp Caceres
One drupal to rule them all - Drupalcamp Caceres
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutions
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBay
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
 
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenutiSymfony CMF: un nuovo paradigma per la gestione dei contenuti
Symfony CMF: un nuovo paradigma per la gestione dei contenuti
 
Intro to Drupal Module Developement
Intro to Drupal Module DevelopementIntro to Drupal Module Developement
Intro to Drupal Module Developement
 
SD PHP Zend Framework
SD PHP Zend FrameworkSD PHP Zend Framework
SD PHP Zend Framework
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp London
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-study
 
Zend Code in ZF 2.0
Zend Code in ZF 2.0Zend Code in ZF 2.0
Zend Code in ZF 2.0
 
Howtobuildyourownframework
HowtobuildyourownframeworkHowtobuildyourownframework
Howtobuildyourownframework
 

Mais de Paul Jones

Your Project Needs a Code Of Conduct, OR ELSE
Your Project Needs a Code Of Conduct, OR ELSEYour Project Needs a Code Of Conduct, OR ELSE
Your Project Needs a Code Of Conduct, OR ELSEPaul Jones
 
Same Thing Happens Every Time
Same Thing Happens Every TimeSame Thing Happens Every Time
Same Thing Happens Every TimePaul Jones
 
Action-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCAction-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCPaul Jones
 
How To Train Your Manager
How To Train Your ManagerHow To Train Your Manager
How To Train Your ManagerPaul Jones
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerPaul Jones
 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHPPaul Jones
 
All You Jokers
All You JokersAll You Jokers
All You JokersPaul Jones
 
Career and Life Management
Career and Life ManagementCareer and Life Management
Career and Life ManagementPaul Jones
 
Framework and Application Benchmarking
Framework and Application BenchmarkingFramework and Application Benchmarking
Framework and Application BenchmarkingPaul Jones
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Paul Jones
 
How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?Paul Jones
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)Paul Jones
 

Mais de Paul Jones (12)

Your Project Needs a Code Of Conduct, OR ELSE
Your Project Needs a Code Of Conduct, OR ELSEYour Project Needs a Code Of Conduct, OR ELSE
Your Project Needs a Code Of Conduct, OR ELSE
 
Same Thing Happens Every Time
Same Thing Happens Every TimeSame Thing Happens Every Time
Same Thing Happens Every Time
 
Action-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCAction-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVC
 
How To Train Your Manager
How To Train Your ManagerHow To Train Your Manager
How To Train Your Manager
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-ControllerAction-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
 
All You Jokers
All You JokersAll You Jokers
All You Jokers
 
Career and Life Management
Career and Life ManagementCareer and Life Management
Career and Life Management
 
Framework and Application Benchmarking
Framework and Application BenchmarkingFramework and Application Benchmarking
Framework and Application Benchmarking
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)
 
How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 

Último

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Último (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

Organizing Your PHP Projects (2010 ConFoo)

  • 1. Organizing Your PHP Projects Paul M. Jones ConFoo, Montréal 10 Mar 2010 http://joind.in/1289
  • 2. Read These • “Mythical Man-Month”, Brooks • “Art of Project Management”, Berkun • “Peopleware”, DeMarco and Lister 2
  • 3. Project Planning in One Lesson • Examine real-world projects • The One Lesson for organizing your project • Elements of The One Lesson • The One Lesson in practice 3
  • 4. About Me • Web Architect • PHP since 1999 (PHP 3) • Solar Framework (lead) • Savant Template System (lead) • Zend Framework (found. contrib.) • PEAR Group (2007-2008) • Web framework benchmarks 4
  • 5. About You • Project lead/manager? • Improve team consistency? • Want to share your code with others? • Want to use code from others? • Want to reduce recurring integration issues? 5
  • 6. Goals for Organizing • Security • Integration and extension • Adaptable to change • Predictable and maintainable • Teamwork consistency • Re-use rules on multiple projects 6
  • 7. Project Research; or, “Step 1: Study Underpinnings” 7
  • 8. Project Evolution Tracks One-Off Heap Standalone App Library ? Modular App Collection Framework CMS 8
  • 9. One-Off Heap • No discernible architecture • Browse directly to the scripts • Add to it piece by piece • Little to no separation of concerns • All variables are global • Unmanageable, difficult to extend 9
  • 10. Standalone Application • One-off heap ++ • Series of separate page scripts and common includes • Installed in web root • Each responsible for global execution environment • Script variables still global 10
  • 11. Standalone Application: Typical Main Script // Setup or bootstrapping define('INCLUDE_PATH', dirname(__FILE__) . '/'); include_once INCLUDE_PATH . "inc/prepend.inc.php" include_once INCLUDE_PATH . "lib/foo.class.php"; include_once INCLUDE_PATH . "lib/View.class.php"; // Actions (if we're lucky) $foo = new Foo(); $data = $foo->getData(); // Display (if we're lucky) $view = new View(INCLUDE_PATH . 'tpl/'); $view->assign($data); echo $view->fetch('template.tpl'); // Teardown include_once INCLUDE_PATH . "inc/append.inc.php"; 11
  • 12. Standalone Application: Typical Include File // expects certain globals if (! defined('APP_CONSTANT')) {     die("Direct access not allowed."); } 12
  • 13. Standalone Application: Typical File Structure index.php # main pages page1.php # page2.php # page3.php # sub/ # sub-section index.php # zim.php # gir.php # inc/ # includes config.inc.php # prepend.inc.php # lib/ # libraries foo.class.php # Bundle1/ # Bundle2/ # 13
  • 14. Standalone Application: Support Structure bin/ # command-line tools cache/ # cache files css/ # stylesheets docs/ # documentation img/ # images install/ # installation scripts js/ # javascript log/ # log files sql/ # schema migrations theme/ # themes or skins tpl/ # templates -- no standard naming or structure -- index.html file in each directory 14
  • 15. Project Evolution Tracks One-Off Heap Standalone App Library ? Modular App Collection Framework CMS 15
  • 16. Modular Application • Standalone application ++ • Same file structure and script style • One additional directory: “modules”, “plugins”, etc • Hooks in the “main” scripts for additional behaviors • Use global variables to coordinate between modules 16
  • 17. CMS • Modular application ++ • General-purpose application broker • All "main" scripts become sub-applications • Still in the web root, still using globals to coordinate 17
  • 18. Application/CMS Projects • Achievo • Eventum • PhpMyAdmin • Code Igniter* • Gallery • Seagull* • Coppermine • Joomla/ • SugarCRM Mambo • DokuWiki • Vanilla • MediaWiki • Drupal • WordPress 18
  • 19. Project Evolution Tracks One-Off Heap Standalone App Library ? Modular App Collection Framework CMS 19
  • 20. Library Collection • Specific, limited logic extracted from an app • Re-used directly in unrelated applications and other libraries • No global variables • Class-oriented • Can exist anywhere in the file system 20
  • 21. Library Project: Typical File Structure Foo.php # Foo Foo/ # Component.php # Foo_Component Component/ # Element1.php # Foo_Component_Element1 Element2.php # Foo_Component_Element2 Bar.php # Bar Bar/ # Task.php # Bar_Task Part/ # Part1.php # Bar_Task_Part1 Part2.php # Bar_Task_Part2 21
  • 22. Framework • Codebase • Library collection • Apps extend from it • Support structure • Bootstrap file • Public assets • Protected assets 22
  • 23. Library/Framework Projects • AdoDB • Lithium • Savant • Cake • Mojavi/Agavi • Seagull * • CgiApp • PAT • Smarty • Code Igniter * • PEAR • Solar • Doctrine • PHP Unit • SwiftMailer • EZ Components • Phing • Symfony • HtmlPurifier • Phly • WACT • Horde • Prado • Zend Framework 23
  • 24. Project Evolution Tracks class- One-Off include- oriented Heap oriented Standalone App Library ? Modular App Collection Framework CMS 24
  • 25. The One Lesson; or, “Step 2: ... ?” 25
  • 26. Organize your project as if it is a library collection.
  • 27. Elements of The One Lesson • Stop using globals • Namespace everything • Class-to-file naming 27
  • 28. 1. Stop Using Globals • Stop using register_globals • Stop using $GLOBALS • Stop using global 28
  • 29. 2. Namespace Everything • Automatic deconfliction of identifiers • Classes (“vendor”) • Functions, variables, constants • Use with $_SESSION, $_COOKIE, etc. keys 29
  • 30. Choosing a Namespace • Project, client, brand, channel • A short word or acronym, not a letter (“Z”) • A unique name, not a generic name related to a task (Date, HTML, RSS, Table, User) 30
  • 32. PHP 5.3 Namespaces namespace vendor; class User {} // relative namespace namespace vendor; $user = new User(); // absolute namespace namespace other; $user = new vendorUser(); 32
  • 33. 3. Class-To-File Naming • Class name maps directly to file name • Vendor_User => Vendor/User.php • Horde, PEAR, Solar, Zend, others • Highly predictable file locations • Lends itself to autoloading 33
  • 34. Class-to-File Naming (PHP 5.2, Horde/PEAR) // studly-caps needs preg_replace(), but: VendorAuthOpenId => ... Vendor/Auth/Open/Id.php? Vendor/Auth/OpenId.php? // underscores just need str_replace() Vendor_Auth_OpenId => Vendor/Auth/OpenId.php 34
  • 35. Class-to-File (PHP 5.3, PSR-0) foo_barpkgMain => /foo_bar/pkg/Main.php foo_barpkgMain_Sub => /foo_bar/pkg/Main/Sub.php • PEAR, Solar, Zend, Doctrine, Lithium, Symfony 2 35
  • 36. The One Lesson In Practice; or, “Step 3: Profit!” 36
  • 37. Extended Effects of The One Lesson • Can be used anywhere (app, module, lib, CMS, framework) • Structure for refactoring and additions • Testing, profiling, and public files can parallel the same structure • Intuitive for new developers • No more include-path woes 37
  • 38. Mambo CMS administrator/ components/ editor/ files/ help/ images/ includes/ Vendor/ index.php installation/ language/ mainbody.php mambots/ media/ modules/ templates/ 38
  • 39. Zend Framework project/ application/ bootstrap.php configs/ controllers/ models/ views/ helpers/ scripts/ library/ Zend/ Vendor/ public index.php 39
  • 40. Lithium app/ config/ controllers/ extensions/ index.php libraries/ models/ resources/ tests/ views/ webroot/ libraries/ lithium/ vendor/ 40
  • 41. Symfony 2 hello/ config/ console/ HelloKernel.php src/ Application/ HelloBundle/ Bundle.php Controller/ Resources/ autoload.php vendor/ symfony/ zend/ vendor/ web/ 41
  • 42. Solar system/ config/ config.php docroot/ index.php public/ include/ Solar.php Solar/ Vendor/ script/ source/ sqlite/ tmp/ 42
  • 43. Solar Apps Are Libraries Too include/ Solar/ Vendor/ App/ Page.php Page/ Layout/ Locale/ Public/ View/ Model/ Gir.php Gir/ Zim.php Zim/ 43
  • 44. Refactoring • Move from existing include-based architecture to class-based architecture ... • ... by functionality • ... by script • Then build scripts out of classes, not includes • Then build apps out of classes, not scripts • Leads to MVC / MVP / PAC architecture 44
  • 46. The One Lesson • Organize your project as if it will be part of a library collection • Avoid globals • Use namespaces for deconfliction • Use class-to-file naming convention 46
  • 47. Goals for Organizing • Security • Integration and extension • Adaptable to change • Predictable and maintainable • Teamwork consistency • Re-use rules on multiple projects 47
  • 49. Thanks! • <http://paul-m-jones.com> • <http://solarphp.com> • Solar Framework talk on Thursday • <http://joind.in/1289> 49