<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.tigerheron.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>software developers</title>
 <link>http://www.tigerheron.com/category/software-developers</link>
 <description>The taxonomy view with a depth of 0.</description>
 <language>en-US</language>
<item>
 <title>Eclipse and PHP</title>
 <link>http://www.tigerheron.com/article/2008/01/eclipse-and-php</link>
 <description>&lt;p&gt;
  In my last &lt;a
  href=&quot;/article/2007/11/tale-two-patterns&quot;&gt;article&lt;/a&gt;, I talked
  about installing PHP. With PHP installed, you will want to start
  writing code, so today&#039;s article is about developing PHP using the
  open source Eclipse integrated development environment (IDE).
&lt;/p&gt;
&lt;p&gt;
  Eclipse started as a Java IDE and evolved into a generic IDE with a
  strong Java bias. If you start out with a standard Eclipse
  installation and without any Eclipse experience, it may take you a
  while to figure out the best way to set it up for use with PHP. This
  article will make the PHP setup fast and easy.
&lt;/p&gt;
&lt;!--break--&gt;

&lt;h2&gt;Why use Eclipse?&lt;/h2&gt;
&lt;p&gt;
  The reasons for using Eclipse are the same as those for using most IDEs:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Syntax highlighting&lt;/li&gt;
  &lt;li&gt;Syntax validation as you type&lt;/li&gt;
  &lt;li&gt;Editing assistance (indentation, auto-completion, etc.)&lt;/li&gt;
  &lt;li&gt;Access to documentation as you type&lt;/li&gt;
  &lt;li&gt;Refactoring assistance&lt;/li&gt;
  &lt;li&gt;Debugging assistance&lt;/li&gt;
  &lt;li&gt;Integration with other tools (documentation creation, source
      control, etc.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Currently, the PHP version of a feature is often more limited than
  the Java version. For example, refactoring is limited to moving
  files; if you want to rename a class, method or function, you will
  need to use the Find/Replace tool (which, luckily, can be applied to
  all files in a project). I expect that the PHP tools will improve
  with time.
&lt;/p&gt;

&lt;h2&gt;PDT&lt;/h2&gt;
&lt;p&gt;
  Eclipse consists of a core set of functions and a flexible plugin
  system. The plugins provide many of the features that we usually
  think of as standard parts of an IDE. This is what makes it possible
  to adapt Eclipse to many computer languages.
&lt;/p&gt;
&lt;p&gt;
  &lt;a href=&quot;http://www.eclipse.org/pdt/&quot;&gt;PDT&lt;/a&gt; is the PHP Development
  Tools plugin, which is essential for working with PHP inside
  Eclipse. Over time, you may choose to enhance your Eclipse
  installation with other plugins, but for PHP development, you only
  need PDT (and its few dependencies).
&lt;/p&gt;

&lt;h2&gt;Getting started: Download&lt;/h2&gt;
&lt;p&gt;
  Begin by downloading the all-in-one &lt;a
  href=&quot;http://download.eclipse.org/tools/pdt/downloads/&quot;&gt;Eclipse/PDT
  ZIP file&lt;/a&gt;. This contains all you need to start using Eclipse with
  PDT.
&lt;/p&gt;
&lt;p&gt;
  If you don&#039;t have Java Runtime Environment (JRE) 5 (or greater)
  installed, then you&#039;ll also need to download the latest &lt;a
  href=&quot;http://www.java.com/en/download/manual.jsp&quot;&gt;JRE&lt;/a&gt;.
&lt;/p&gt;

&lt;h2&gt;Getting started: Install&lt;/h2&gt;
&lt;p&gt;
  Start by installing the JRE, if you need it.
&lt;/p&gt;
&lt;p&gt;
  The Eclipse all-in-one package comes as a ZIP file. On Windows, you
  can extract the contents to C:&amp;#92;Program Files. This will create a
  folder called &quot;eclipse&quot;. For easy access, copy the eclipse.exe file
  in the folder and paste it as a shortcut on the desktop.
&lt;/p&gt;

&lt;h2&gt;Getting started: Configure&lt;/h2&gt;
&lt;p&gt;
  Start Eclipse by running the eclipse.exe file. This will ask you to
  select a &quot;workspace&quot;, a folder that will store a collection of your
  projects. You can have more than one workspace.
&lt;/p&gt;
&lt;p&gt;
  Eclipse will suggest a location for the workspace. If you&#039;re happy
  with it, click OK. On Windows, I would suggest using
  something like My Documents&amp;#92;Eclipse. If you don&#039;t intend to create
  multiple workspaces, select &quot;Use this as the default and do not ask
  again&quot; before clicking on OK (you can change your mind later).
&lt;/p&gt;
&lt;p&gt;
  Eclipse should appear and display the Welcome screen (you can return
  to the Welcome screen through the Help menu). Now I will introduce
  you to Eclipse&#039;s rather intimidating preferences system: select &lt;span
  class=&quot;navPath&quot;&gt;Window &amp;gt; Preferences&lt;/span&gt;. Under &lt;span
  class=&quot;navPath&quot;&gt;PHP &amp;gt; PHP Interpreter&lt;/span&gt;, select PHP 4 or 5.
&lt;/p&gt;
&lt;p&gt;
  There are many other options you will want to customize, but this is
  sufficient to get started. You&#039;ll return to this menu many times to
  tweak how Eclipse works.
&lt;/p&gt;

&lt;h2&gt;Getting started: Update&lt;/h2&gt;
&lt;p&gt;
  You should also become familiar with Eclipse&#039;s update system. Select
  &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Software Updates &amp;gt; Find and
  Install &amp;gt; Search for updates of the currently installed features
  &amp;gt; Finish&lt;/span&gt;. Select a mirror or let Eclipse select one for you.
  Eclipse will now begin a rather slow search for updates. You can
  place the update dialog into the background and continue to work
  while the search takes place.
&lt;/p&gt;
&lt;p&gt;
  When Eclipse locates all the updates, a window will appear, showing
  you your update options. Select everything and begin the update.
  Once you have installed all updates, you may need to restart
  Eclipse. Your installation is now up-to-date.
&lt;/p&gt;
&lt;p&gt;
  The update method is also the way you add new features to Eclipse.
  Use &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Software Updates &amp;gt; Find and
  Install&lt;/span&gt;, but this time select &quot;Search for new features to
  install&quot;. You&#039;ll be able to search for features on a collection of
  sites.
&lt;/p&gt;
&lt;p&gt;
  For example, let&#039;s say you use doxygen to generate your PHP
  documentation. You would click on &quot;New Remote Site&quot;, enter &quot;Eclox&quot; for
  the name and http://download.gna.org/eclox/update/ for the URL. This
  creates a new entry in the sites list.
&lt;/p&gt;
&lt;p&gt;
  You can visit &lt;a href=&quot;http://www.eclipseplugincentral.com/&quot;&gt;Eclipse
  Plugin Central&lt;/a&gt; to find additional plugins to install. But let&#039;s
  leave that for later.
&lt;/p&gt;

&lt;h2&gt;Creating a project for existing PHP code&lt;/h2&gt;
&lt;p&gt;
  Your Eclipse installation may coincide with the creation of a new
  PHP project, but it is more likely that you already have existing
  code you want to use within Eclipse. This is where most people get a
  little stuck&amp;mdash;if you know the magic incantation, the process is
  easy.
&lt;/p&gt;
&lt;p&gt;
  Let&#039;s say you have a PHP Web site at My Documents&amp;#92;Sample&amp;#92;Web Site and
  that you test the Web site using the local server address
  http://localhost/sample.
&lt;/p&gt;
&lt;p&gt;
  Fire up Eclipse and select &lt;span class=&quot;navPath&quot;&gt;File &amp;gt; New &amp;gt;
  PHP Project&lt;/span&gt;. Enter a project name. Disable the &lt;span
  class=&quot;navPath&quot;&gt;Project contents &amp;gt; Use default&lt;/span&gt; toggle and
  browse to the My Documents&amp;#92;Sample&amp;#92;Web Site folder. Click &lt;span
  class=&quot;navPath&quot;&gt;Next&lt;/span&gt;. The files in the My
  Documetns&amp;#92;Sample&amp;#92;Web Site folder are now part of an Eclipse project.
&lt;/p&gt;
&lt;p&gt;
  You probably also reference code through a PHP include path. Select
  &lt;span class=&quot;navPath&quot;&gt;Libraries &amp;gt; Add External Folder&lt;/span&gt; to
  include folders in your Web site&#039;s include path. Click &lt;span
  class=&quot;navPath&quot;&gt;Finish&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Our project now appears in Eclipse&#039;s PHP Explorer pane. Eclipse will
  place a .project file in the My Documents&amp;#92;Sample&amp;#92;Web Site folder,
  but your content is otherwise undisturbed. You are ready to use
  Eclipse. You can also continue to work on your code using your
  existing development tools.
&lt;/p&gt;

&lt;h2&gt;Editing with Eclipse&lt;/h2&gt;
&lt;p&gt;
  Using the PHP Explorer pane, you can double-click on a file and have
  it appear in Eclipse&#039;s editor pane. The features here are pretty
  standard, so I won&#039;t talk about them too much. You may want to
  return to the preferences dialog to customize the editing features.
&lt;/p&gt;
&lt;p&gt;
  One nice editor feature is called &quot;code assist&quot;. Eclipse will pop up
  various displays that offer documentation or auto-completion help.
  If the code assist popup doesn&#039;t appear automatically, you can call
  it with Ctrl + Space. One caveat: if you have enabled the Emacs key
  bindings, the magic sequence is Alt + /.
&lt;/p&gt;

&lt;h2&gt;Executing PHP&lt;/h2&gt;
&lt;p&gt;
  You can still run your Web pages by typing
  http://localhost/sample/some_page.php into your Web browser. But
  let&#039;s try running the page from eclipse.
&lt;/p&gt;
&lt;p&gt;
  First, some setup: Using &lt;span class=&quot;navPath&quot;&gt;Window &amp;gt;
  Preferences &amp;gt; PHP &amp;gt; PHP servers&lt;/span&gt;, we create a new
  server, Sample, with a URL of http://localhost/sample. If you would
  like to use your default browser, go to &lt;span
  class=&quot;navPath&quot;&gt;General &amp;gt; Web Browser&lt;/span&gt;, select &lt;span
  class=&quot;navPath&quot;&gt;Use external browser&lt;/span&gt; and enable &lt;span
  class=&quot;navPath&quot;&gt;Default system Web browser&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Open up your Web page in the editor. Select &lt;span
  class=&quot;navPath&quot;&gt;Run &amp;gt; Run As &amp;gt; PHP Web Page&lt;/span&gt;. In the
  dialog that appears, verify that the &lt;span class=&quot;navPath&quot;&gt;Launch
  URL&lt;/span&gt; is correct. The page will appear in your Web browser.
&lt;/p&gt;
&lt;p&gt;
  You may notice that the URL has many parameters attached to it.
  These are for coordinating with the debugger. This may be a bug in
  Eclipse since debug parameters should only be added when debugging a
  script.
&lt;/p&gt;
&lt;p&gt;
  Go to &lt;span class=&quot;navPath&quot;&gt;Run &amp;gt; Open Run Dialog&lt;/span&gt;. You&#039;ll
  see that you can create a &quot;run configuration&quot; that controls what
  happens when you select &lt;span class=&quot;navPath&quot;&gt;Run&lt;/span&gt;. For my
  &quot;sample&quot; project, I right-clicked on &lt;span class=&quot;navPath&quot;&gt;PHP Web
  Page&lt;/span&gt; and selected &lt;span class=&quot;navPath&quot;&gt;New&lt;/span&gt;. I set the
  debugger to XDebug, the PHP Server to Sample and the file to
  /Sample/index.php. On the &lt;span class=&quot;navPath&quot;&gt;Common&lt;/span&gt; tab, I
  toggled Run under &lt;span class=&quot;navPath&quot;&gt;Display in favorites
  menu&lt;/span&gt;.
&lt;/p&gt;
&lt;p&gt;
  Now I can run the index.php page by selecting the Run icon on the tool
  bar and then selecting the run configuration I created from the tool
  bar drop down. Using this method, the page appears without the
  debugging parameters attached.
&lt;/p&gt;
&lt;p&gt;
  As far as I can tell, you would have to create one run configuration
  per page. Or, as I pointed out earlier, you could just enter the
  page address directly in your browser and bypass Eclipse.
&lt;/p&gt;

&lt;h2&gt;Debugging PHP&lt;/h2&gt;
&lt;p&gt;
  If you have your system set up to use either the Zend debugger or
  XDebug, it&#039;s easy to debug with Eclipse.
&lt;/p&gt;
&lt;p&gt;
  Configuring PHP for debugging is beyond the scope of this article.
  The Eclipse portion of the setup involves using &lt;span
  class=&quot;navPath&quot;&gt;Run &amp;gt; Open Debug Dialog&lt;/span&gt; to get to a dialog
  very similar to the Run Dialog. Create a configuration for debugging
  index.php and enabled the Debug toggle on the Common tab.
&lt;/p&gt;
&lt;p&gt;
  On the tool bar, you can use the debug button drop-down to select your
  debug configuration. Normally, the debugger will break on the first
  line.
&lt;/p&gt;
&lt;p&gt;
  When you start debugging, Eclipse will offer to switch to the PHP
  Debug perspective, which will give you the right panes and controls
  to run the debugger.
&lt;/p&gt;

&lt;h2&gt;Additional resources&lt;/h2&gt;
&lt;p&gt;
  I hope these instructions give you a head start at using Eclipse for
  PHP. Here are some other places you may get assistance.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://www.eclipse.org/&quot;&gt;http://www.eclipse.org/&lt;/a&gt;, the home
  page of the Eclipse project.&lt;/li&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://wiki.eclipse.org/PDT/&quot;&gt;http://wiki.eclipse.org/PDT&lt;/a&gt;, the home
  page for PDT.&lt;/li&gt;
  &lt;li&gt;Visit &lt;a
  href=&quot;http://wiki.eclipse.org/PDT/FAQ&quot;&gt;http://wiki.eclipse.org/PDT/FAQ&lt;/a&gt; for a list of frequently asked questions about PDT.&lt;/li&gt;
  &lt;li&gt;Use &lt;span class=&quot;navPath&quot;&gt;Help &amp;gt; Help Contents&lt;/span&gt; and
  open up the &lt;span class=&quot;navPath&quot;&gt;PDT User Guide&lt;/span&gt; for the
  online manual.&lt;/li&gt;
&lt;/ul&gt;
</description>
 <comments>http://www.tigerheron.com/article/2008/01/eclipse-and-php#comments</comments>
 <category domain="http://www.tigerheron.com/category/eclipse">Eclipse</category>
 <category domain="http://www.tigerheron.com/category/ide">IDE</category>
 <category domain="http://www.tigerheron.com/category/php">PHP</category>
 <category domain="http://www.tigerheron.com/category/software-developers">software developers</category>
 <category domain="http://www.tigerheron.com/category/xdebug">XDebug</category>
 <pubDate>Wed, 09 Jan 2008 16:29:44 +0000</pubDate>
 <dc:creator>developer</dc:creator>
 <guid isPermaLink="false">92 at http://www.tigerheron.com</guid>
</item>
<item>
 <title>High-performance debugging</title>
 <link>http://www.tigerheron.com/article/2007/09/high-performance-debugging</link>
 <description>&lt;p&gt;
  In this article, I will show you how to use PHP 5 input filters to support
  debug, trace and assert statements so that a one-line change
  disables these statements and restores your script to full production
  performance.
&lt;/p&gt;
&lt;!--break--&gt;

&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;
  The typical debug statement looks like this:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;echo &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;p&amp;gt;Hello, I am a debug statement&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
  This is the workhorse of PHP debugging—at least, when we aren&#039;t
  using a debugger. We insert it as needed and remove it when done.&lt;/p&gt;
&lt;p&gt;
  Sometimes the debug code takes some work to produce or has some
  permanent benefits. The easiest way to preserve it is by placing it
  in a comment:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;// echo &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;p&amp;gt;Hello, I am a complicated debug statement&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  This can be inconvenient if we  frequently need to enable
  debugging or if we need to enable multiple debug statements. So the
  next variation is to enable debug statements based on a flag:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; ($debugEnabled) echo &lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;p&amp;gt;Hello, I am a debug statement&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  Now, we can turn a number of debug statements on or off with a single
  setting. But we&#039;ve also added some overhead that occurs even when
  the debug statements are disabled. We have also added some extra
  typing that will make us less inclined to use this tool.&lt;/p&gt;
&lt;p&gt;
  You can gain some flexibility by using:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;debug(&lt;span class=&quot;str&quot;&gt;&quot;Hello, I am a debug statement&quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  This opens the door to creating an elaborate debug system, but adds a performance penalty. Not only do we have the overhead of the function call, but the function argument is evaluated each time
  the statement is executed, whether debugging is enabled or not.
  We&#039;re back to:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; ($debugEnabled) debug(&lt;span class=&quot;str&quot;&gt;&quot;Hello, I am a debug statement&quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  PHP provides an&lt;span class=&quot;code&quot;&gt; &lt;a
  href=&quot;http://php.net/manual/en/function.assert.php&quot;&gt;assert()&lt;/a&gt;&lt;/span&gt;
  function which helps check program logic and can be disabled in
  php.ini. This function could be subverted to serve as the base for a
  debug system, but it appears to function much like the &lt;span
  class=&quot;code&quot;&gt;debug&lt;/span&gt; function above, at least in PHP 5.2.4. &lt;/p&gt;
&lt;p&gt;
  For code that services thousands of requests per hour, the small
  overhead of these debug statements is significant and they are
  rarely left in place.&lt;/p&gt;

&lt;h2&gt;Why use debug statements?&lt;/h2&gt;
&lt;p&gt;Before going further, I need to answer the obvious question: why not use debuggers, profilers or other tools instead of debug statements? &lt;/p&gt;
&lt;p&gt;The answer is that it&#039;s not an either-or; each tool has its place. Debug statements are sometimes faster to use or provide information that is easier to understand. For example, the ability to easily  trace all  database queries and send the output to a log file might be more effective in resolving some problems than stepping through the code with a debugger. &lt;/p&gt;
&lt;p&gt;
  The debug system I will present to you has these goals:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;It should support debug, trace and assert statements.&lt;/li&gt;
  &lt;li&gt;It should be easily and completely disabled for production code.&lt;/li&gt;
  &lt;li&gt;It should be easy to enter debug statements. &lt;/li&gt;
  &lt;/ul&gt;

&lt;h2&gt;Setting the stage&lt;/h2&gt;
&lt;p&gt;
  Let me start with the three simple debugging classes I will use in
  this article. Each class name is prefixed with &quot;th&quot; for &quot;Tiger
  Heron&quot;.&lt;/p&gt;
&lt;p&gt;
  The first is the &lt;span class=&quot;code&quot;&gt;thDebug &lt;/span&gt;class, which
  allows us to format the output appropriately for Web or CLI use:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thDebug
{
    static public function debug($msg)
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (php_sapi_name() == &lt;span class=&quot;str&quot;&gt;&#039;cli&#039;&lt;/span&gt;) echo $msg . &lt;span class=&quot;str&quot;&gt;&quot;n&quot;&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; echo &lt;span class=&quot;str&quot;&gt;&#039;&amp;lt;p&amp;gt;&#039;&lt;/span&gt; . nl2br($msg) . &lt;span class=&quot;str&quot;&gt;&#039;&amp;lt;/p&amp;gt;&#039;&lt;/span&gt;;
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  The second class is thTrace. Tracing can be enabled or disabled, and
  you can set a threshold for the level of messages that are
  displayed.&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thTrace
{
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $isEnabled = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $level = 0;

    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function enable($isEnabled) { self::$isEnabled = $isEnabled; }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function isEnabled() { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; self::$isEnabled; }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function setLevel($level) { self::$level = $level; }

    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function trace($msg, $level = 0)
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (self::$isEnabled &amp;amp;&amp;amp; $level &amp;lt;= self::$level) {
            thDebug::debug($msg);
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  The  final debug class is thAssert, which generates an message only
  if an assertion fails. The &quot;precondition&quot; and &quot;postcondition&quot;
  methods are aliases for assert. Assertions, like tracing, can be enabled or disabled at run-time. &lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thAssert
{
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $isEnabled = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;

    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function enable($isEnabled) { self::$isEnabled = $isEnabled; }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function isEnabled() { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; self::$isEnabled; }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function assert($cond, $file, $line, $title=&lt;span class=&quot;str&quot;&gt;&#039;Assertion&#039;&lt;/span&gt;)
        { &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!$cond) thDebug::debug(&lt;span class=&quot;str&quot;&gt;&quot;$title failed! $file:$line&quot;&lt;/span&gt;);  }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function precondition($cond, $file, $line)
       { self::assert($cond, $file, $line, &lt;span class=&quot;str&quot;&gt;&#039;Precondition&#039;&lt;/span&gt;); }
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function postcondition($cond, $file, $line)
      { self::assert($cond, $file, $line, &lt;span class=&quot;str&quot;&gt;&#039;Postcondition&#039;&lt;/span&gt;); }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;To enable the entire debug system, we use: &lt;/p&gt;
&lt;div&gt;
 &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thDebugManager
{
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $isEnabled = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $isFilterRegistered = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;

    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function enable($isEnabled)
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (!$isFilterRegistered &amp;amp;&amp;amp; $isEnabled) {
            require &lt;span class=&quot;str&quot;&gt;&#039;thDebugFilter.inc&#039;&lt;/span&gt;;
            $isFilterRegistered = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
        }
        self::$isEnabled = $isEnabled;
    }

    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function isEnabled() { &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; self::$isEnabled; }
}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The references to the filter are explained in the next section. It might seem to make more sense to place this code in the thDebug class, but we want to avoid loading any debug-related classes when they are not used. The &lt;span class=&quot;code&quot;&gt;thDebugManager&lt;/span&gt; contains the minimum amount of code that we must load all the time.&lt;/p&gt;
&lt;h2&gt;PHP input filters&lt;/h2&gt;
&lt;p&gt;
  We&#039;ll now introduce the key PHP 5 feature we&#039;ll use for our
  solution: the input filter. We will create a filter that will
  transform PHP code as it is loaded, essentially acting as a
  dynamic pre-processor.&lt;/p&gt;
&lt;p&gt;
  I started with some code from Adam Trachtenberg&#039;s book, &lt;em&gt;&lt;a
  href=&quot;http://www.amazon.com/gp/product/0596006365?ie=UTF8&amp;amp;tag=tigerheron-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0596006365&quot;&gt;Upgrading
  to PHP 5&lt;/a&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; alt=&quot;&quot;
  src=&quot;http://www.assoc-amazon.com/e/ir?t=tigerheron-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0596006365&quot;
  border=&quot;0&quot;&gt;&lt;/em&gt;, and tweaked it a bit to create a reusable abstract
  class. To create a new filter, simply subclass this class and
  implement the missing function.&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thAbstractStreamFilter
    extends php_user_filter
{
    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $data;
    &lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; $bucket;

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function onCreate()
    {
        $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data = &lt;span class=&quot;str&quot;&gt;&#039;&#039;&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;
    }

    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function filter($&lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt;, $&lt;span class=&quot;kwrd&quot;&gt;out&lt;/span&gt;, &amp;amp;$consumed, $closing)
    {
        &lt;span class=&quot;kwrd&quot;&gt;while&lt;/span&gt; ($bucket = stream_bucket_make_writeable($&lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt;)) {
            $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data .= $bucket-&amp;gt;data;
            $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;bucket = $bucket;
            $consumed = 0;
        }

        $consumed += strlen($&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data);
        $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data = $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;filterData($&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data);
        $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;bucket-&amp;gt;data = $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data;
        $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;bucket-&amp;gt;datalen = strlen($&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data);
        stream_bucket_append($&lt;span class=&quot;kwrd&quot;&gt;out&lt;/span&gt;, $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;bucket);
        $&lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;-&amp;gt;data = &lt;span class=&quot;str&quot;&gt;&#039;&#039;&lt;/span&gt;;
        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; PSFS_PASS_ON;
    }

    &lt;span class=&quot;kwrd&quot;&gt;abstract&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function filterData($data);
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  I&#039;ll refer you to Adam&#039;s book for the details on input filters.&lt;/p&gt;

&lt;h2&gt;The Debug filter&lt;/h2&gt;
&lt;p&gt;
  Using the &lt;span class=&quot;code&quot;&gt;thAbstractStreamFilter &lt;/span&gt;class, I
  can finally create the core of my debug solution, the &lt;span
  class=&quot;code&quot;&gt;thDebugFilter&lt;/span&gt;:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thDebugFilter
    extends thAbstractStreamFilter
{
    &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function filterData($data)
    {
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//CODEs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;$1&#039;&lt;/span&gt;, $data);
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//DBGs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;thDebug::debug($1);&#039;&lt;/span&gt;, $data);
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//TRACEs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;if (thTrace::isEnabled()) thTrace::trace($1);&#039;&lt;/span&gt;, $data);
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//ASSERTs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;if (thAssert::isEnabled()) &#039;&lt;/span&gt; .
                &lt;span class=&quot;str&quot;&gt;&#039;thAssert::assert($1, __FILE__, __LINE__);&#039;&lt;/span&gt;, $data);
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//PRECONDs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;if (thAssert::isEnabled()) &#039;&lt;/span&gt; .
                &lt;span class=&quot;str&quot;&gt;&#039;thAssert::precondition($1, __FILE__, __LINE__);&#039;&lt;/span&gt;, $data);
        $data =
            preg_replace(
                &lt;span class=&quot;str&quot;&gt;&#039;!//POSTCONDs*([^nr]*)!m&#039;&lt;/span&gt;,
                &lt;span class=&quot;str&quot;&gt;&#039;if (thAssert::isEnabled()) &#039;&lt;/span&gt; .
                &lt;span class=&quot;str&quot;&gt;&#039;thAssert::postcondition($1, __FILE__, __LINE__);&#039;&lt;/span&gt;, $data);

        &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; $data;
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  I&#039;ve introduced some special &amp;quot;keywords&amp;quot; to PHP: &lt;span
  class=&quot;code&quot;&gt;//CODE&lt;/span&gt;, &lt;span class=&quot;code&quot;&gt;//DBG&lt;/span&gt;, &lt;span
  class=&quot;code&quot;&gt;//TRACE&lt;/span&gt;, &lt;span class=&quot;code&quot;&gt;//ASSERT&lt;/span&gt;,
  &lt;span class=&quot;code&quot;&gt;//PRECOND&lt;/span&gt; and &lt;span
  class=&quot;code&quot;&gt;//POSTCOND&lt;/span&gt;. When the filter is not used, these
  all look like PHP comments. When the filter is enabled, each of
  these statements is transformed into live code.&lt;/p&gt;
&lt;p&gt;
  You could do everything  with //&lt;span class=&quot;code&quot;&gt;CODE&lt;/span&gt;. This
  is used to hide or expose any arbitrary line of code. The other
  statements reduce the typing needed to use the debug classes.&lt;/p&gt;
&lt;p&gt;Here are some examples and their translations &lt;/p&gt;
&lt;div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;rem&quot;&gt;//CODE $x = $x + 10; 
  -&amp;gt; $x = $x + 10;&lt;/span&gt;
&lt;span class=&quot;rem&quot;&gt;//DBG &quot;This is a debug statement.&quot;&lt;/span&gt;
  -&amp;gt; thDebug::debug(&amp;quot;This is a statement.&amp;quot;);
&lt;span class=&quot;rem&quot;&gt;//TRACE &quot;Level 4 message&quot;, 4&lt;/span&gt;
  -&amp;gt; if (thTrace::isEnabled()) thTrace::trace(&amp;quot;Level 4 message&amp;quot;, 4, __FILE__, _LINE__);
&lt;span class=&quot;rem&quot;&gt;//ASSERT $x == 10&lt;/span&gt;
  -&amp;gt; if (thAssert::isEnabled()) thAssert::assert($x == 10, __FILE__, __LINE__);
&lt;span class=&quot;rem&quot;&gt;//PRECOND $data == null&lt;/span&gt;
  -&amp;gt; if (thAssert::isEnabled()) thAssert::precondition($x == 10, __FILE__, __LINE__);
//POSTCOND $data != null
  -&amp;gt; if (thAssert::isEnabled()) thAssert::postcondition($x == 10, __FILE__, __LINE__);
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  Before using an input filter, we have to register it. The following
  line does the job:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;stream_filter_register(&lt;span class=&quot;str&quot;&gt;&#039;phpCode.thDebug&#039;&lt;/span&gt;,&lt;span class=&quot;str&quot;&gt;&#039;thDebugFilter&#039;&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;h2&gt;Tying it all together with __autoload&lt;/h2&gt;
&lt;p&gt;Now that we have the filter, how do we use it? Here is one way: &lt;/p&gt;
&lt;div&gt;
&lt;pre class=&quot;csharpcode&quot;&gt;function thRequire($file)
{
    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (thDebugManager::isEnabled()) {
        require &lt;span class=&quot;str&quot;&gt;&#039;php://filter/read=phpCode.thDebug/resource=&#039;&lt;/span&gt; . $file;
    }
    &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; {
        require $file;
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;You would call &lt;span class=&quot;code&quot;&gt;thRequire()&lt;/span&gt; in place of any require statement. You would need similar methods for &lt;span class=&quot;code&quot;&gt;require_once&lt;/span&gt;, &lt;span class=&quot;code&quot;&gt;include&lt;/span&gt; and &lt;span class=&quot;code&quot;&gt;include_once&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I prefer using anothe PHP 5 feature, the &lt;span class=&quot;code&quot;&gt;__autoload()&lt;/span&gt; method. It  allows us to
  dispense with most &lt;span class=&quot;code&quot;&gt;include&lt;/span&gt; and &lt;span class=&quot;code&quot;&gt;require&lt;/span&gt; statements, at least for
  classes. When a class is needed but not defined, the  function
  registered with &lt;span class=&quot;code&quot;&gt;__autoload &lt;/span&gt;will be given a
  chance to load the class. Most of my code is objected-oriented, so this works well for me.&lt;/p&gt;
&lt;p&gt;
  Here is the &lt;span class=&quot;code&quot;&gt; &lt;/span&gt;class that that handles class
  loading. For this article, I have deliberately created a very basic autoloader: it assumes that the class name maps to a file with an &amp;quot;inc&amp;quot; extension and exists in the include path. &lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; thAutoload
{
    &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; function load($className)
    {
        &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (thDebugManager::isEnabled()) {
            require
                &lt;span class=&quot;str&quot;&gt;&#039;php://filter/read=phpCode.thDebug/resource=&#039;&lt;/span&gt; .
                $className . &lt;span class=&quot;str&quot;&gt;&#039;.inc&#039;&lt;/span&gt;;
        }
        &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; {
            require $className . &lt;span class=&quot;str&quot;&gt;&#039;.inc&#039;&lt;/span&gt;;
        }
        return true;
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
  I still need to register my autoload handler with  &lt;span
  class=&quot;code&quot;&gt;__autoload()&lt;/span&gt;, but that would be bad
  style. There&#039;s only room for one &lt;span
  class=&quot;code&quot;&gt;__autoload()&lt;/span&gt; method, so to allow sharing with other packages, I use
  &lt;span class=&quot;code&quot;&gt;spl_autoload_register()&lt;/span&gt; instead:&lt;/p&gt;
&lt;div&gt;
  &lt;pre class=&quot;csharpcode&quot;&gt;spl_autoload_register(array(&lt;span class=&quot;str&quot;&gt;&#039;thAutoload&#039;&lt;/span&gt;, &lt;span class=&quot;str&quot;&gt;&#039;load&#039;&lt;/span&gt;));&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;If we were really using other autoloaders, we should also check if the file exists and return false if it doesn&#039;t, so as to give other autoloaders a chance to try loading the class. &lt;/p&gt;
&lt;p&gt;In any case, all the pieces are present and the solution is complete:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;span class=&quot;code&quot;&gt;thAutoload&lt;/span&gt; and &lt;span class=&quot;code&quot;&gt;thDebugManager&lt;/span&gt; must be loaded with a normal &lt;span class=&quot;code&quot;&gt;require&lt;/span&gt; or &lt;span class=&quot;code&quot;&gt;include&lt;/span&gt;. &lt;/li&gt;
  &lt;li&gt;To enable debugging, call &lt;span class=&quot;code&quot;&gt;thDebugManager::enable(true)&lt;/span&gt; before loading any  classes containing debug statements. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;So how well does it perform?&lt;/h2&gt;
&lt;p&gt;
  One way to see if I achieved my goals is to itemize all the overhead
  imposed by the debugging system &lt;em&gt;when it is disabled&lt;/em&gt;.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;The compiler will have to compile the &lt;span
  class=&quot;code&quot;&gt;thDebugManager &lt;/span&gt;class.&lt;/li&gt;
  &lt;li&gt;The &lt;span class=&quot;code&quot;&gt;thAutoload &lt;/span&gt;class also a small bit of code that is compiled but not used. &lt;/li&gt;
  &lt;li&gt;One &lt;span class=&quot;code&quot;&gt;if&lt;/span&gt; statement and a function call is executed per loaded
  class.&lt;/li&gt;
  &lt;li&gt;The compiler has to discard some extra comment lines.&lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;To me, the overhead appears acceptably low. However, for the highest performing scripts, where you count nanoseconds, this is still not good enough. Here are options for increasing performance:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Using &lt;span class=&quot;code&quot;&gt;__autoload()&lt;/span&gt; is slightly slower than direct loads, so the scripts could use &lt;span class=&quot;code&quot;&gt;thRequire()&lt;/span&gt;. &lt;/li&gt;
  &lt;li&gt;The &lt;span class=&quot;code&quot;&gt;thDebugManager&lt;/span&gt; can make the &lt;span class=&quot;code&quot;&gt;$isEnabled&lt;/span&gt; variable public—bad OO style, but it eliminates a function call. &lt;/li&gt;
  &lt;li&gt;Need more speed? Comment out the unused parts of thRequire(). This involves changing a few lines, but it is far easier than commenting out all the debug statements, which is what you would be doing if you used debug statement in the typical fashion.&lt;/li&gt;
  &lt;li&gt;Need even more? Edit all thRequires into straight requires. If we&#039;re talking high-performance scripts, you shouldn&#039;t have very many of these anyway. While this is not very convenient, you can enable a lot of debugging capability with a few edits.&lt;/li&gt;
  &lt;li&gt;Finally, use an opcode cache. This eliminates all compiler overhead. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Getting the code&lt;/h2&gt;
&lt;p&gt;
  I&#039;ve put all the code together in a ZIP file, along with a sample
  sorting class that uses the debugging features and a main program
  that can be run using the command-line version of PHP.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/files/downloads/high-performance-debugging.zip&quot;&gt;Download high-performance-debugging.zip&lt;/a&gt; ( 7KB) &lt;/p&gt;
&lt;h2&gt;Where to go from here&lt;/h2&gt;
&lt;p&gt;
  The ability to trasnform code dynamically opens up a lot of pre-processing
  possibilities: how about running the code through the C pre-processor? Or a macro processor like m4? Or even adding new syntax to the PHP language? I&#039;ll explore some options in later articles.&lt;/p&gt;
&lt;h2&gt;A special request for opcode cache developers &lt;/h2&gt;
&lt;p&gt;The extra filter processing creates  undesirable overhead that could be easily eliminated with an opcode cache, but it is unclear how many opcode caches support input filters. The dynamic nature of input filters make it almost impossible to determine when the cached code needs to be updated (after all, I could create a filter where the generated code would vary depending on the time of day) and this could discourage developers from adding suport.&lt;/p&gt;
&lt;p&gt;I hope instead that the developers will provide some way of enabling this capability with the caveat that the user must manage the cache, either manually or programmatically. Without some caching support, there is a limited future for using this technique in production code. &lt;/p&gt;
</description>
 <comments>http://www.tigerheron.com/article/2007/09/high-performance-debugging#comments</comments>
 <category domain="http://www.tigerheron.com/category/assert">assert</category>
 <category domain="http://www.tigerheron.com/category/autoload">autoload</category>
 <category domain="http://www.tigerheron.com/category/debugging">debugging</category>
 <category domain="http://www.tigerheron.com/category/input-filters">input filters</category>
 <category domain="http://www.tigerheron.com/category/opcode-caches">opcode caches</category>
 <category domain="http://www.tigerheron.com/category/performance">performance</category>
 <category domain="http://www.tigerheron.com/category/php">PHP</category>
 <category domain="http://www.tigerheron.com/category/software-developers">software developers</category>
 <category domain="http://www.tigerheron.com/category/trace">trace</category>
 <pubDate>Mon, 17 Sep 2007 03:14:32 +0000</pubDate>
 <dc:creator>developer</dc:creator>
 <guid isPermaLink="false">88 at http://www.tigerheron.com</guid>
</item>
<item>
 <title>In the beginning...</title>
 <link>http://www.tigerheron.com/article/2007/09/beginning</link>
 <description>&lt;p&gt;
  Welcome to the first of a series of PHP articles. I hope to present
  you with useful tips, novel ideas, and code you can use or adapt. My
  reward will be learning more about PHP, both from researching the
  articles and from the suggestions and criticism you offer.
&lt;/p&gt;
&lt;!--break--&gt;
&lt;p&gt;
  All my PHP articles will use PHP 5 as a base. Many will focus on OO
  programming and PHP performance, two topics I hope will generate
  lively discussions.
&lt;/p&gt;
&lt;p&gt;
  Many of the articles will include some working code. The code is
  provided under a Creative Commons license, and may be used in
  commercial and non-commercial works with attribution. I ask that you
  not sell the code except when embedded as part of a larger system.
&lt;/p&gt;
&lt;p&gt;
  Here&#039;s a list of the articles I plan to write. I will update it as I
  go. If any of these topics sounds interesting, subscribe to my
  developers&#039; feed now to ensure you receive the article when it comes
  out.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;/article/2007/09/high-performance-debugging&quot;&gt;High-performance debugging&lt;/a&gt;*&lt;br&gt;

    &lt;em&gt;In support of the goPHP5 movement (and to start this series
    with a bang), I&#039;ll show you how to include debug statements in 
    production code with no overhead. The  technique can be extended to 
    support dynamic pre-processing.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;/article/2007/11/tale-two-patterns&quot;&gt;A Tale of Two Patterns&lt;/a&gt;&lt;br&gt;

    &lt;em&gt;Using junction points and Perl, I&#039;ll show you how to easily
    manage multiple PHP installations on Windows, including multiple
    versions of PHP 4, PHP 5 and PHP GTK.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/article/2008/01/eclipse-and-php&quot;&gt;
    Eclipse and PHP&lt;/a&gt;&lt;br&gt;
    &lt;em&gt;Create, edit and test PHP with the Eclipse 3.3 IDE.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;/article/2008/03/first-steps-php-booting-script-part-1&quot;&gt;First steps with PHP&amp;mdash;booting a script, Part 1&lt;/a&gt;&lt;br&gt;
    &lt;a href=&quot;/article/2008/04/first-steps-php-booting-script-part-2&quot;&gt;First steps with PHP&amp;mdash;booting a script, Part 2&lt;/a&gt;&lt;br&gt;
    &lt;em&gt;Learn how to get PHP scripts going in a flexible and efficient way.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Autoload: the good, the bad and the ugly&lt;br&gt;
    &lt;em&gt;The first in a set of articles introducing PHP 5&#039;s
    __autoload() method.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Autoload: Using class loaders*&lt;br&gt;

    &lt;em&gt;Following up on the previous article, I&#039;ll discuss the
    contentious topic&amp;nbsp; of class loaders.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Autoload: Overcoming session problems&lt;br&gt;

    &lt;em&gt;Mixing __autoload() and sessions spells &quot;trouble&quot;. I&#039;ll cover
    one possible solution.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Extending PHP syntax by using streams*&lt;br&gt;

    &lt;em&gt;This article returns to territory covered by my first article
    and suggests ways in which the PHP language can be easily extended
    by using streams.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    How much performance do you really need?*&lt;br&gt;

    &lt;em&gt;To achieve maximum PHP performance you may have to sacrifice
    some coding flexibility. Should you?&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Short and sweet: compression&lt;br&gt;

    &lt;em&gt;How to compress for bandwidth savings.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Increase performance through caching&lt;br&gt;

    &lt;em&gt;How to benefit from server and browser caching.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    PHP and CSS*&lt;br&gt;

    &lt;em&gt;Does it make sense to use PHP code in your CSS? Can you do it
    without sacrificing performance?&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Database classes that make your life easier&lt;br&gt;

    &lt;em&gt;This topic could easily become a set of articles. Can we
    improve on the mysqli library? How well do high-level database
    classes perform?&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Iterators you can use&lt;br&gt;

    &lt;em&gt;PHP 5 comes with a basic set of iterator classes. Here are
    some extensions.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Components*&lt;br&gt;

    &lt;em&gt;I&#039;ll present my Component classes and ask: fantastic building
    blocks or huge performance drain?&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    An OO approach to forms and wizards&lt;br&gt;

    &lt;em&gt;I lose tons of time developing forms and wizards. Here&#039;s my
    OO-approach to making their creation easier.&lt;/em&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Opcode caching: the manual&lt;br&gt;

    &lt;em&gt;I don&#039;t know what I&#039;ll write, but I know this is an article I&#039;d like to read!&lt;/em&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  I hope you&#039;ll visit and contribute your ideas. Subscribe now!
&lt;/p&gt;
&lt;p style=&quot;font-size: smaller&quot;&gt;
* Unusual topics that should lead to some great debates.
&lt;/p&gt;
</description>
 <comments>http://www.tigerheron.com/article/2007/09/beginning#comments</comments>
 <category domain="http://www.tigerheron.com/category/php">PHP</category>
 <category domain="http://www.tigerheron.com/category/software-developers">software developers</category>
 <pubDate>Sun, 16 Sep 2007 02:11:02 +0000</pubDate>
 <dc:creator>developer</dc:creator>
 <guid isPermaLink="false">87 at http://www.tigerheron.com</guid>
</item>
</channel>
</rss>
