domenica 7 ottobre 2012

Emacs PHP class template generator

I use GNU Emacs as my default for a lot of stuff, including developing in PHP. Unluckily the great php-mode does not include a lot of common stuff to handle with OOP PHP programming. So I decided to develop a PHP class template generator, a lisp function that prompts for the class name (that will be capitalized and will be stored in a file with the same name) and for an optional comment, and then generates a class skeleton in a new buffer, saving the result to a file. Actually there are two versions of the function, the base one php-class executes the other php-class-in-path with the current working directory as path. The path is used to let Emacs know where to save the new buffer. In both cases, if a file with that name is already existent, the function aborts.
Therefore, calling M-x php-class and inserting a class name will make a new buffer appearing, with the class skeleton and a new file with such class will be saved.

Nessun commento: