Your SlideShare is downloading. ×
Building API's
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Building API's

291
views

Published on

This session will cover how to write effective API modules utilizing the hook system found in Drupal in a way that makes your module extensible and pluggable. …

This session will cover how to write effective API modules utilizing the hook system found in Drupal in a way that makes your module extensible and pluggable.
We’ll look at some of the Drupal modules that do this effectively(Views, Fields/CCK, etc.) and also look at a recent example, The Piecemaker API module, where I implemented this strategy.

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
291
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Building API’s
    A.K.A. making your module extensible
  • 2. Who Am I?
    Adam A. Gregory
    Drupal Developer, Themer, Consultant, and Trainer
    Using Drupal For 5+ years
    Built and maintain numerous modules/themes on Drupal.org
    Been involved in Drupal projects large and small
    Recently released my first API module, Piecemaker API, & currently converting the Theme Editor module to more of an API in D7
  • 3. What We’ll Cover
    What is an API
    How it applies to building modules
    How do I code an API module?
    Planning
    Proper structures (hooks, classes)
    Drupal Coding Standards
    Code, Test, Code, Test
    Give Examples (example.api.php)
    Release into the wild
    Real World Examples
  • 4. What is an API?
    Application Programming Interface
    Allows other code/programs/modules/etc. to reutilize it’s utilities, resources, and/or services
    Provides a more efficient code base in Drupal (ussually)
    Drupal is essentially a big API, or rather a group of API’s
  • 5. How do I code an API module?
    Code, Pray, Test, Yell, Throw computer in pool, Give up, Become a monk.
  • 6. Planning
    A good plan violently executed now is better than a perfect plan executed next week.
    - General George S. Patton
    Use a whiteboard, mindmap, pad of paper
    Think through possible uses, by both devs and end users
    Steal ideas! (It’s OK, that’s what Open Source is for)
  • 7. Proper Structures
    Classes
    Drupal is moving slowly but surely to a more OOP approach so try to plan for that.
    In D7 there is auto loading of Classes so it makes for more efficient code.
    In order to utilize classes you must initialize classes dynamically, not statically. (May also apply to methods depending on your module use)
    Classes can easily be extended so they are preferable.
  • 8. Proper Structures
    Hooks
    You can write an entire API that only utilizes hooks.
    Hooks will be needed even in API that are mostly OOP.
    The entire Drupal system was built as a hooker so it is easily understood by most developers
  • 9. Drupal Coding Standards
    In order for your module to be extensible it MUST, MUST, MUST conform to Drupal coding standards and practices.
    Common mistakes
    Not using a theme() function for ANY html output
    Not using drupal_alter() to allow other modules access
    Not Documenting properly: PHPDoc, example.api.php
  • 10. Code, Test, Code, Test
  • 11. Give Examples
    Document you code thoroughly
    Use your own hooks if possible
    Provide an example.api.php that shows some implementations of your hooks and classes
    Code the first module that implements the API and include it.
  • 12. Release it into the wild!
    You’ve done it right?
    Not so fast my friend…
    No you have to support it.
    Provide documentation on Drupal.org
    Answer Issues
    Fix bugs
    Provide Support
    Make improvements
    Make new releases
    Lather, Rinse, Repeat
  • 13. Lets Look At Some Code
    Views, Fields, Piecemaker
  • 14. Q&A
    You ask. I answer. Lets keep it simple… Not the questions, just the subtitle.
  • 15. Adam A. Gregory
    Web:
    Causecast.org
    NewhallWeb.com
    Twitter:
    @adamgregory
    Email:
    arcaneadam@gmail.com
    Adam@NewhallWeb.com
    Drupal:
    arcaneadam

×