1

1 - 5   [5]

PHP Function Lookup from XEmacs

Also relates to PHP and Apache, X11

Ok, I have gone all XEmacs, and am really impressed. For the best part of two years now I have been using UltraEdit for must web scripting with a little bit of Eclipse on the side for command line testing with PHP5 development. With a large amount of the development work now migrated to my IBook, it was time to seek out a new editor. Currently I am undecided between Eclipse, BBEdit, Vim, Quanta, Kate and XEmacs, although I am very drawn to the latter.

Despite the learning curve, with a bit of Lisp knowledge in hand, the power of XEmacs quickly becomes apparent. Of course an essential feature for any scripting language is syntax highlighting and efficient function lookup. The first is easy enough - add the prog-modes package (which includes an Emacs lisp file for PHP major mode) and all other dependant packages from the package manager. I also enabled syntax highlighting by default in ~/.xemcas/init.el with:


(require 'font-lock)

While perusing the settings for PHP mode from the Options menu (and directly from the package file prog-modes/php-mode.el) I discovered that the key command sequence Ctrl C Ctrl F performs a search for the function currently selected at php.net. This was a problem since the machine is not going to be on a permanant connection. So, I decided to store the PHP Documentation on my local server. Nothing out of the ordinary, except it give me the opportunity to use the RewriteMap directive in the Apache configuration.

  1. Grab the multi-file PHP documentation from php.net. And extract all files to a suitable location on disc (note there are over two thousand separate HTML files and they will all be extracted to same directory, so make sure it is the right place!)
  2. Create a name-based virtual server to access the documentation locally by first adding a new machine name (eg phpdocumentation) to the Netinfo Database in OSX.
  3. Add a virtual server entry to the httpd configuration file. I currently have the system configured to reboot Apache with a different principle conf file for each PHP version - as with my Window 98 box - so I put virtual server directives in one of the user conf files (from /etc/httpd/users) instead.

    
    <VirtualHost 127.0.0.1>
      ServerName phpdocumentation
      
      # Rewrite Directives will go here…
      
      DocumentRoot "/path/to/php/documentation/dir"
      <Directory "/path/to/php/documentation/dir">
        AllowOverride All
        Options +FollowSymLinks
      </Directory>
    </VirtualHost>
    
  4. Now, instead of hacking the Lisp code in php-mode.el, which could readily be destroyed by a future update of prog-modes, I decided to throw in a rewrite rule to fix the request URI. From XEmacs the request would be for http://phpdocumentation/function_name, so the following might work:

    
    RewriteEngine On
    RewriteRule  ^([-_a-z0-9])$ /function.$1.html
    

    Sadly not! All function help files take the form function.[the-function-name].html. And that is where I hit the stumbling block! Underscores are replaced by hyphens in the HTML file names for functions.

I was reluctant to resort to Lisp hacking, so decided to try one of the rewrite directives I have had little use for previously - RewriteMap.

  1. Create an executable script that can be called in the rewriting process to replace the underscores. I choose Perl and, due the simplicity of the rewrite, only needed one more line of code than the actual Apache manual:

    
    #!/usr/bin/perl
    # php-func-map.pl
    
    # avoid buffered I/O
    $| = 1;
    
    while (<STDIN>) {
      # globally change the underscore to a hyphen
      s/_/-/g;
      print $_;
    }
    
  2. Then set up the rewriting directives - for RewriteMap these have to go under the VirtualHost directive in the conf rather than in .htaccess file.

    
    RewriteEngine On
    RewriteMap php-func-map prg:/path/to/php-func-map.pl
    RewriteRule /([-_a-z0-9]+)$ /function.${php-func-map:$1}.html
    

And that is that. The magic is in ${php-func-map:$1} which will pass the pattern match $1 to the file defined by php-func-map and get back a PHP manual friendly file name. Of course this could be extended further to perform searches beyond just the manual's function set but servers my purpose well for the time being. So, now when I forget if the needle or the haystack goes first, a quick key combination and the manual entry is available.

Posted on Jun 15, 2005 at 18:58:33. [Comments for PHP Function Lookup from XEmacs- 0]

XUL Preview In UltraEdit

Also relates to Firefox and Co and XUL

While the XUL Console discussed in the previous post is a useful tool for learning the XUL language by example with instant testing, it embeds the <window> within the XUL Console itself, so GUI display is not accurate. This can probably be overriden with JavaScript, but since I am still in the early days of XUL discovery focusing on the markup and CSS I decided to set up a Tool Configuration in UltraEdit instead, to allow XUL applications to be run straight out of the editor. First the XUL package needs to be registered in installed-chrome.txt under the Mozilla root:


content,install,url,resource:/chrome/my_xul_file/content/
locale,install,url,resource:/chrome/my_xul_file/locale/en-US/
skin,install,url,resource:/chrome/my_xul_file/skin/

For some inexplicable reason I also found I had to manually enter the skin framework into the application chrome.rdf file:


<RDF:Seq about="urn:mozilla:skin:modern/1.0:packages">
  
  [..]
  
  <RDF:li 
    resource="urn:mozilla:skin:modern/1.0:my_xul_file"/>
</RDF:Seq>

[..]

<RDF:Description about="urn:mozilla:skin:modern/1.0:findfile"
               c:baseURL="resource:/chrome/my_xul_file/skin/">
  <c:package resource="urn:mozilla:package:my_xul_file"/>
</RDF:Description>

The installed-chrome.txt file should have done this for me. Anyway, with the package registered, an UltraEdit Tool Configuration can be configured with the following command line:


"C:\Program Files\mozilla.org\Mozilla\mozilla.exe" _
  -nosplash -chrome "chrome://%n/content/%n%e"

Where _ is a line continuation. By adding the tool to the menubar, my XUL previews are just one click away. Note that if another instance of Mozilla is running at the same time, the preview will not update since it will use the chrome files from the instance that is already running. So I view the XUL Tutorial and Programmer's Reference in Firefox while I work on my XUL.
[ Micro who?! ;) ]

Posted on Mar 07, 2004 at 20:46:32. [Comments for XUL Preview In UltraEdit- 1]

The Installation Bane

This post does not relate to any other topics

It is always a pleasure [sarcasm] after installing new software to discover that it has scrambled the functioning of other regular programmes on my system. Earlier today I stumbled across the Style Studio CSS editor and decided to give it a quick try out, being on the look-out for a lightweight CSS auto-completion tool I could tie in with Ultra Edit (just to help out all those times the memory fades and I have to dive for a reference book to look up a property value). The features list promised a lot, perhaps too much for my requirements as I had previously found with TopStyle Pro and Style Master.

Unfortunately it didn't meet expectations being quite resource heavy and failing a number of times in graphical display. Well the delight came when I entered the Norton control panel to reset options and discovered the Windows Scripting engine was no longer working! (I suppose it is too much to ask software vendors to give an idea of how their software will mangle the operating system!)

Fortunately, I always use Install Watch Pro for new software installs from Windows executables, and so quickly opened it up to see what damage CSS had caused. While I was amused to see it had created over 50,000 new registry entries for the actual software itself, I was less pleased to see it had totally reconfigured the type library for the VB Script dynamic link library to point to an older version, installed to a subdirectory of the new software's root during installation! As it happened I only had to restore about 10 registry keys, but certainly without Install Watch Pro's clear snapshot of the preinstallation configuration I would not have know where to begin! I can't recommend this freeware software enough.

The outcome, two hours of the day gone and none the wiser!? As for CSS editor, I actually decided just to update TopStyleLite to version 3 on my system. This serves my main requirement, however it would be nice to find a tool that gives site reports similar to those produced in TopStyle Pro and Style Studio, without the added burden of a full blown CSS/HTML Editor.

Posted on Feb 29, 2004 at 02:03:23. [Comments for The Installation Bane- 0]

The J-Bay Of J-Editors

Also relates to Java

Ok, have played around with Eclipse this weekend, and I am totally converted. All the IDEs I had tried up till now have been removed from my system, and Eclipse has become my only Java editor. It is superb! The features are just too many to list right now, but with realtime tool tips from the JavaDoc and source file, error checking, advanced file compare and rollback and auto-compile on save (to name a few) my personal Java development is coming along rapidly. And that is in only 36 hours! The interface is crisp, the icons are visually pleasing and instructive and the well documented start-up tutorial got me up and running in no time with workspaces, perspectives and views. Creating custom classpaths to the Open Office API and MySQL Bridge was a breeze. And if all this wasn't enough to get me excited, the quick fix feature put the icing on the cake.

Massive respect to the team that dedicate their time to develop this Open Source project. Maybe once I have a real feel for the system, I will have a look at a few of the plugins for PHP, Perl, XML and SQL. Even try and get involved when I can find the time. The Point Break of non-commercial/low-budget Java IDEs!

Posted on Sep 14, 2003 at 17:45:13. [Comments for The J-Bay Of J-Editors- 0]

Java Editors

Also relates to Java

I seem to have been through a multitude of IDEs the last couple of years, with each one bringing benefits that the one before may have lacked. For quite a while my preferred environment was HTML-Kit with my emphasis on HTML, CSS and Javascript development.

When I started working professionally with PHP, I went for PHPEd which wasn't without its quirks, the worst being a repetitive run time error when debugging, which I (and NuSphere tech support) still haven't resolved now.

I found Style Master a beneficial tool when I was advancing my CSS knowledge, although it had a bad habit of draining my GDI resources considerably allowing me enough room to run only one browser concurrently - actually the latest release of Top Style looks pretty exciting, with added support for accessibility testing.

XML Spy was an absolute godsend, especially for learning XSD. However, once the trial expired I was reluctant to invest in a peculiar support system that expired on the same date regardless of when the product was purchased. Fortunately this has been changed with the latest release, XMLSpy 2004, and this IDE is high on my wishlist.

The last six months or so I have actually found myself doing most coding in UltraEdit, which I have found to be an efficient lightweight IDE with enough features to support my requirements and not overburdened (as my copy of HTML-Kit rapidly became) with superfluous extensions. I generally find myself using this for all XML, HTML, CSS, Javascript and PHP development. Some of the other languages, which I have really only trodden the surface with, Python, TCL/TK, Curl come with very useful IDEs as part of the development kit, or Vim/Emacs (a totally new world!) with regard to shell scripting within Cygwin..

However the one language I had never really quite found the right tool for at a low budget and lightweight was Java. Lack of quality autocomplete and class management in the IDEs I used elsewhere always let them down for Java development. Since I have being doing a few projects on the side recently with Apache Xerces and generally developing my Swing knowledge, I decided a few months ago a good Java IDE was essential. Well, I have tried a few. For a while I thought that JCreator was a good enough solution, however SitePad has edged past it with better class/package management and a more customisable interface through its inbuilt adoption of Javascript scripting tools. SitePad has a slightly steeper learning curve but I havent found this to be too much of a disadvantage. Also, the creator, Chet Murphy, was very prompt to reply and helpful when I contacted him with a few queries.

So, have I found my environment of choice? It appears not yet, since the other day I stumbled across the Eclipse Open Source project. Why I never found this earlier, I don't know, but this looks like it could be a different solution all together. Being a strong advocate of Open Source Software, and appreciating the advantage of not having to fork out the same expense everytime an upgrade occurs (or lose out), I therefore have an excuse to put the feet up tonight, catch up on fourty winks and wait for the colossal 66 megabytes of the SDK to ween their way down my phone line. Will report back with a verdict…

Posted on Sep 12, 2003 at 23:35:44. [Comments for Java Editors- 0]

Breadcrumbs Trail

[ Home ] -> TW Blog -> IDEs
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.005 seconds