ExtJS Easy PHP Wrapper (Miscellaneous)

ExtJS EasyWrapper for PHP;

ExtJS is a really cool JavaScript library for generating web GUIs.
Everything works really nicely when all you want are simple forms, but it generally doesn’t take long before you want to control the rendered JavaScript based on some server-based logic (i.e., only show these fields to “admins”, or load values from a SQL database based on the selected ID and show them in the form). Pretty soon, you are wrapping the JavaScript in PHP control structures and embedded little snippets of PHP to set values. Then, what do you know, your code looks like unmaintainable rubbish. Not to mention that if you are an Emacs user (like me), it messes up all the nice syntax highlighting and auto-indenting. Hence, I decided to invest an hour or two in creating a PHP-wrapper that would allow me to write PHP but render ExtJS JavaScript. It turns out it is pretty simple, as my code will show.

ExtJS code uses hierarchical JavaScript object structures where the objects are specialised by setting properties. A similar structure of objects can be specified in PHP, and now that PHP 5 supports the magic methods of get andset, and __call that makes it is easy to set arbitrary properties of an object and you can also call arbitrary functions! such as I did it in USING THE CODE section!

This is the key to why the mapping ends up being simple!

Download ExtJS Easy PHP Wrapper (Miscellaneous)

Leave a Reply

Your email address will not be published. Required fields are marked *