Plugins And Making Your Own
Upcoming SlideShare
Loading in...5
×
 

Plugins And Making Your Own

on

  • 4,878 views

Presentation given on symfonycamp 2008

Presentation given on symfonycamp 2008

Statistics

Views

Total Views
4,878
Views on SlideShare
4,871
Embed Views
7

Actions

Likes
3
Downloads
80
Comments
0

4 Embeds 7

http://new.op5.org 2
http://www.slideshare.net 2
http://www.sfexception.com 2
http://www.rpi-virtuell.net 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Plugins And Making Your Own Plugins And Making Your Own Presentation Transcript

  • Plugins and making your own Lambert Beekhuis Lead developer at DOP
  • Why plugins?
    • Re-use common functionality
      • For yourself...in multiple projects
      • Or better...for the symfony community
        • Sharing/learning
      • How should I build a Plugin?
  • Plugins as of today (ok, Thursday 11 th of september) Stats 269 plugins 688 releases 134 developers 4104 users symfony 1.0 symfony 1.1 symfony 1.2 All 231 123 60 Bound to Propel 75 39 19 Bound to Doctrine 6 2 1
  • Popular plugins
    • Popular Plugins on 2007/08/14top-20-symfony-plugins (symfony-project blog top-20-symfony-plugins)
    • 1. sfSimpleCMSPlugin
    • 2. sfGuardPlugin
    • 3. sfDoctrinePlugin
    • 4. sfPropelActAsNestedSetBehaviorPlugin
    • 5. sfMediaLibraryPlugin
    • 6. sfSimpleBlogPlugin
    • 7. sfSimpleForumPlugin
    • 8. sfFeed2Plugin
    • 9. sfgWidgetsPlugin
    • 10. sfThumbnailPlugin
    • 11. sfUJSPlugin
    • 12. sfControlPanelPlugin
    • 13. sfFormValidationPlugin
    • 14. sfMogileFSPlugin
    • 15. sfLightboxPlugin
    • 16. sfCaptchaPlugin
    • 17. sfNiftyPlugin
    • 18. sfPrototypeWindowPlugin
    • 19. sfPropelLoadbalancerPlugin
    • 20. sfSavvyPlugin
    • 21. sfYzClientSideValidationPlugin
    • Today (2009/09/11)
    • sfGuardPlugin
      • Authorisation
    • sfSimpleCMSPlugin
      • Content Management
    • sfDoctrinePlugin
      • Doctrine ORM
    • sfPropelActAsNestedSetBehaviorPlugin
      • Propel-trees
    • sfLucenePlugin
      • Searching
    • sfThumbnailPlugin
      • Thumbnails/resizing
    • sfMediaLibraryPlugin
      • Manage web-assets (images, PDF, flash objects)
    • sfExtjs2Plugin
      • Possible to write external JavaScript
  • Top down development ‘ it works’ is not enough! Good structure!
  • Developing cycles
    • Development - cycle
    • Idea or requirements
    • Design/principle/philosofie
    • Coding
    • Testing
    • Documentation
    • Maintenance
    • Comments....
    • Fun part
    • Prior to coding or ...?
    • Lot of focus (to much?)
    • Do you test systematically?
    • Essential! often ‘forgotten’!
    • Not a fun part...but with the community is much better!
  • Talking as a consultant.... Urgent Not urgent Important Not important
  • Used for development Urgent Not urgent Important ‘ It works’ Debugging Software structure Documentation Refactoring Not important Features never used
  • Plugins
    • Make a plugin:
    • Independant of your application
    • Upgradable
    • Customizable
    PHP PHP Symfony Database ORM Your Application plugin plugin customize customize plugin customize
  • Plugin - basics
    • A plugin can contains all options grouped,
    • (similar to in your application)
    • Config
      • Config.php
    • Data
      • Fixtures
    • Lib
      • Helper/
      • Model/ schema.yml: propel: _attributes: { package plugins.lbSaasPlugin.lib.model }
      • Others (e.g. Filters)
    • Modules
      • Actions
      • Templates
      • Validate
      • Config
        • Module.yml
        • View.yml
    • Enable a plugin in your application
    • Settings.yml
    • Application-config/app.yml
    • New in symfony 1.1
      • Handle plugin dependencies at installation
      • Customizing the plugin-schema
    all: lb_saas_plugin: enable_saas_filter: on # switch the extra Saas-filter on/off saas_profile_class: Client # PHP-object name for Saas-object saas_profile_field_name: saas_id all: .settings: enabled_modules: [default, sfGuardAuth]
  • Installing a plugin - basics
    • symfony 1.0
    • Install a plugin
      • > cd myproject > php symfony plugin-install channelName/pluginName > php symfony cc
    • Enable modules in your application:
      • In: apps/ myApplication /config/settings.yml
      • All: .settings: enabled_modules: [ yourPluginModule ]
    • Follow additional instructions from readme
    • Clear cache
      • > php symfony cc
    • symfony 1.1
    • Install a plugin
      • > cd myproject > php symfony plugin:install pluginName
  • Based on the ‘SaasPlugin’
    • ‘ Software as a Service’ authentication
      • User has access to one or more Saas-en
      • Extension on sfGuardPlugin
    • Clean URLs e.g. www.application.comsaasOnemoduleaction (after yesterday: saasOne.application.commoduleaction)
    • Administration interfaces for
      • Application admin
      • ‘ saasAdmin’
    • Limit data-retrieval for the selected Saas (based on Propel right now)
  • Customizing a Plugin
    • Rule
      • never alter the code found in the plugins/ directory
    • use settings
      • that can be changed in the application app.yml
    • Replace functions in your application
      • create a module of the same name in your own application.
    • Allow replacing
      • Create ‘empty’ actions/models in your plugin, e.g.
        • Actions
        • Model
  • Replacing model functions plugins/xxxPlugin/lib/model/om/BasexxxObject.php plugins/xxxPlugin/lib/model/map/xxxObjectMapBuilder.php plugins/xxxPlugin/lib/model/xxxObject.php plugins/xxxPlugin/lib/model/om/BasexxxObject.php plugins/xxxPlugin/lib/model/map/xxxObjectMapBuilder.php plugins/xxxPlugin/lib/model/xxxObject.php plugins/xxxPlugin/lib/model /plugin/ PluginxxxObject.php class pluginxxxObject extends BasexxxObject { // your plugin functions } class xxxObject extends pluginxxxObject { // empty } Generated by ORM (propel) (do not touch) Your functions Can be replaced in your application- module
  • Replacing plugin functions
    • Add empty module in your application
      • Add a template in this module
      • Add security.yml in your application
      • Add actions (requires proper plugin setup)
    • Add model-classes in your application
      • Requires proper plugin-setup
  • Other ways – routing/filters/...
    • Routing ‘injection’, e.g. in ‘user’ public static function add_default_saas_routes { $r = sfRouting::getInstance(); $r->prependRoute('saas_default', /:clientslug/s/:module/:action/*');
    • Use an additional filter for global functions (e.g. Filters the URL and checks against allowed Saas)
    Your appliction/config/filters.yml rendering: ~ web_debug: ~ saas: class: saasFilter condition: %APP_LB_SAAS_PLUGIN_ENABLE_SAAS_FILTER% security: ~ # generally, you will want to insert your own filters here cache: ~ common: ~ flash: ~ execution: ~
  • Deploying plugins
    • For own purpose
    • Use SVN:external for use in multiple projects
    • Publish as symfony-project.org
    • Define the new Plugin at www.symfony-project.org/plugin/new
    • Naming conventions
      • Propel dependency
        • E.g sfPropelActAsNestedSetBehaviorPlugin
      • First two letters/initials can be your initials (or just use sf)
        • E.g. dwPrototypeTooltipPlugin
    • Define a proper readme!
    • Select a license
    • add a package.xml file at the root of the plug-in directory
    • Upload your PEAR package
  • Plugins - conclusions
    • Powerfull way to extend the framework functions
    • Many plugins available
      • Usefullness and quality depends
      • As of today, not easy to find usefullness and quality symfony-project.org
    • Many options for customization
      • If Plugin is developed correctly!