Category: "Web Sites"

What you can do with FireBug

  • Debug javascript
  • Examine the DOM tree
  • Understand the CSS
  • Change the CSS in the browser to see its effect
  • See the layout of the page
  • Determine the dimensions of page elements
  • See the page components and understand the page load process
  • View the HTTP headers
  • Evaluate javascript expressions and commands interactively
  • Use debug write (console.debug) statements to issue debug data
  • Add breakpoints
  • Profile your page

If you use it, all the time, contribute. Ask your employer to support it.

Log ALL Errors

Graceful error trapping and display is important, both during development and after deployment. It is also good to have debug control that is manageable through environment variables. One nice solution is to use SetEnv in .htaccess or a .conf file.

Regardless of the trap and display code, be sure to log all errors, so you can resolve them if they occur. Check the error log (usually /etc/httpd/logs/error_log) frequently.

Along those lines, although using isset in Smarty template will not cause an error, if the Smarty variable inside the call is not set, a PHP will be thrown (http://smarty.net/manual/en/language.modifier.default.php). Possible solutions:

  • Do nothing - disk space is cheap and the logs get rotated (this is the wrong answer)
  • Initialize all Smarty variables for the templates in the PHP (a good answer)
  • Use PHP to initialize the template variables within the template, using {php} tags (also a valid approach)
  • Use AJAX to populate forms (may be much more difficult and take longer)

The best approach depends on the application architecture, and may vary by template within the application.

It is good to look at the compiled templates to see how they are constructed.

Drupal RPM spec file generator module

A Drupal RPM generator module could scan the modules installed and extract the following information:

  • Source file (full URL)
  • Requires - the modules required to support each module
  • Provides - the name of the service/capability/feature provided by each module
  • Conflicts with - modules which cannot be installed with each module

The standard BUILD, SPECS, SOURCE, RPM, SRPM directories can be used for the build process. The Drupal RPM generator would write .spec files to the SPECS directory for each module. .rpmmacros would indicate the target directory, and other common constants.

This allows a development environment to be quickly converted from a .tgz installation to an RPM managed production server.

email forwarders

email addresses such as sales, careers, info, and help should always be forwarders. This allows them to be independent of the people that handle them. It also simplifies development and content management by using the final address, which must then be changed prior to launch.

OOP Web

In virtually every web application - performance should take precedence over everything.

PHP (and many other languages) are interpretive. The code is read over and over.

  • Organize the files such that the most commonly used code is first.
  • Keep files small.
  • Use a good architecture.
  • Don’t read data or access information that won’t be used. If it won’t go to the client, on every request, don’t read it.
  • Validate on the client side first, and don’t send the data to the server if it isn’t valid.
  • Perform quick validation and escaping to protect the server on the server side.
  • Cache files on the client whenever possible.
  • Cache information on the server, use session variables for anything that will be used on every request. Consider storing ACL data in a session variable, but be aware of security risks.
  • Be aware of PHP best practices, and the impacts of double-quoted strings.