Drupal is a hot technology and now is a good time to start developing in the space. This post will point you in the right direction, and provide you Online links that you can look to for more detail.
Learning proper Drupal module development can take some time, but if you’re hacking together your first site and tinkering with modules you’ve downloaded, there are a few things that will help you move a lot quicker.
1)First off, you’ll need to know what hooks are. People who are familiar with event driven or aspect oriented programming might recognize the hook system. It’s a way for a module to say, “I’ve gotten to this point in processing, does anyone want to do something before I go further?” Beginning Drupal has a good chapter that covers Drupal hooks.
The module announces this by calling module_implements, module_invoke, or module_invoke all, passing in the name of the hook as the first parameter; for example, module_invoke_all(‘user_logout’, $user).
Other modules can “hook in” and have their code run at that point in code execution by creating a function, called a hook implementation, that uses a particular naming convention. The naming convention is the implementing module’s name followed by the hook_name; for example, if your module were named “foo”, foo_user_logout would do something anytime a user logs out.
2)Using the command line can really speed up your development. With the Drush project, you can do things like download and enable modules, clear the cache, or reinstall your site directly from the command line. Other modules can also provide Drush commands, so check the full list of commands by typing “drush”, and Foundation Drupal 7 has an entire appendix devoted to drush.
3)The Devel module suite has a bunch of great tools for developers. When the Devel module is enabled, you can debug with functions like:
dpm which prints a variable to the screen in an easy to read way using the Krumo library.
dd which outputs the variable to a file in the temp directory instead of to the screen.
dargs which prints the arguments passed to the current function. This can be especially helpful to see what arguments are passed to a hook implementation.
This post should help you get started developing and debugging in Drupal.
Learning proper Drupal module development can take some time, but if you’re hacking together your first site and tinkering with modules you’ve downloaded, there are a few things that will help you move a lot quicker.
1)First off, you’ll need to know what hooks are. People who are familiar with event driven or aspect oriented programming might recognize the hook system. It’s a way for a module to say, “I’ve gotten to this point in processing, does anyone want to do something before I go further?” Beginning Drupal has a good chapter that covers Drupal hooks.
The module announces this by calling module_implements, module_invoke, or module_invoke all, passing in the name of the hook as the first parameter; for example, module_invoke_all(‘user_logout’, $user).
Other modules can “hook in” and have their code run at that point in code execution by creating a function, called a hook implementation, that uses a particular naming convention. The naming convention is the implementing module’s name followed by the hook_name; for example, if your module were named “foo”, foo_user_logout would do something anytime a user logs out.
2)Using the command line can really speed up your development. With the Drush project, you can do things like download and enable modules, clear the cache, or reinstall your site directly from the command line. Other modules can also provide Drush commands, so check the full list of commands by typing “drush”, and Foundation Drupal 7 has an entire appendix devoted to drush.
3)The Devel module suite has a bunch of great tools for developers. When the Devel module is enabled, you can debug with functions like:
dpm which prints a variable to the screen in an easy to read way using the Krumo library.
dd which outputs the variable to a file in the temp directory instead of to the screen.
dargs which prints the arguments passed to the current function. This can be especially helpful to see what arguments are passed to a hook implementation.
This post should help you get started developing and debugging in Drupal.
Tuesday, 3 April 2012
// //
2
comments
//
2 comments to "Debugging and Developing in Drupal"





Anonymous says:
This is really innovative and a new idea, I like this concept and the way it is carried out in so light and cool manner. I concur with your conclusions and will eagerly look forward to your future updates.
Joomla Developer
Unknown says:
At this time it looks like Drupal is the preferred blogging platform out there right now. (from what I have read) Is that what you are using on your blog?
Best Regards:
Daffodil Software Ltd.
Cloud Application Development