Sei sulla pagina 1di 37

Best Practises For

Drupal Maintenance

Robert Castelo, Code Positive Ltd.


If You’re In
Charge Of A Project
Get A Good Team

• Developer
• Themer
• Designer
• Configuration(er)
How To
Evaluate Candidates?
Look At Involvement
www.drupal.org
user account

See:
• modules
• themes
• documentation
• years involved
Check Work Quality

Coder module
tests for compliance with Drupal coding style
www.drupal.org/project/coder
Client Testimonials

What do heads of
other Drupal
projects say about
the candidate?
If You’re Configuring
A Website
Modules & Themes

modules & themes directories are for core Drupal


- NEVER install into them
Sites Directory
Every file you add to your
Drupal site should live in
the ‘sites’ directory.

✔ This makes it easier to keep


your site updated.
Sites Default


sites/default/modules - used by a single site.


Recommended in most cases.
Sites All

Installed modules used by multiple sites.


Only recommended if all sites use the same code base.
Modules Sub-directories

Modules can be separated into contrib and custom


(internal development) for easier maintenance
Update Status
Keep up to date (Drupal 6 & 7 built in)
Drupal 5: drupal.org/project/update_status
If You’re
Developing A Site
Separate Logic / Presentation
Module Theme
Modular

• Easier to Code

• Code is Re-usable

• Easier to Maintain
Rapid Development
& Less Maintenance

• Less Code To Create

• Less Code to Maintain


Avoid Spaghetti Code

• Standard API

• Strict Formatting
Code Legibility

Give functions and variables meaningful labels


www.drupal.org/coding-standards
Code Documentation

Well documented code improves maintainability


API Module
Convert documentation in code into web pages
api.drupal.org www.drupal.org/project/api
Quick Tips
✔ t(‘Example text’)
Enable interface text to be translated
✔ l() and url() for links
<?
✔ <?php
Don’t add ?> at end of file
Local Module
Create a Local module to add
small custom tweeks
Views In Module
Store your custom Views in a module

• improves performance
• easier to move (dev to live)
• puts views in version control
www.mc-kenna.com/drupal/2009/05/
managing-drupal-views-the-proper-way
Keep PHP Out Of
The Database
• Easier to maintain code
• Easier to find
• Easier to upgrade
• Under version control
If you must put PHP in a block, view, node....
put code in a function in your Local module
then just call the function
Use Version Control
Enables code to be rolled back,
and teams to work on same code
CVS
http://www.nongnu.org/cvs
SVN
http://subversion.tigris.org/
GIT
http://git-scm.com/
...
Maintenance Tools
Devel Module
Essential development tools
http://drupal.org/project/devel
Devel Module
Also good for theme building
Coder Module
Automatic validation of module & themes
www.drupal.org/project/coder
Simple Test
Automated tests of your code
check new code doesn’t break the old
www.drupal.org/project/simpletest
Masquerade Module
Log in as a different user, test roles
www.drupal.org/project/masquerade
Questions
Image Credits
http://www.iconeden.com/icon/free/get/milky-a-free-vector-iconset

http://www.flickr.com/photos/elyob/213880107

http://www.flickr.com/photos/evilerin/3078856253

http://www.flickr.com/photos/28796269@N05/3225819794

http://www.flickr.com/photos/egadapparel/3212007816

http://www.flickr.com/photos/wildcat_dunny/318732519/

Potrebbero piacerti anche