Wednesday, May 21st, 2008
Category: Dojo
, PHP
The Zend Framework aims to be a top notch framework for building next generation Web applications in PHP. Dojo has similar aims on the front-end side, so they decided to join forces to provide an integration layer. If you like the combination you will have a better, tighter, way to build your applications.
What we see in the initial release is:
-
JSON-RPC Server: We are re-working the Zend_Json_Server that has
been in our incubator since, oh, what? 0.2.0? and never released to
actually follow a specification:
JSON-RPC. This
will allow it to work seamlessly with Dojo, as well as other toolkits
that have JSON-RPC client implementations. I have actually completed
work on this, though the proposal is waiting to be approved; if you want
to check it out, you can find it in the
ZF svn.
The original Zend_Json_Server implementation will be abandoned. It was
never fully tested nor fully documented, which has prevented its
release. Additionally, since it implemented its own ad-hoc standard, it
did not provide the type of interoperability that a true JSON-RPC server
implementation will provide. I am excited that we will finally be able
to provide a standards-compliant solution for general availability.
One final note: there are currently two different JSON-RPC
specifications, 1.0 and 2.0. My goal is to support each, though for the
time being, only version 1.0 will be supported, as that is the version
Dojo currently targets.
-
dojo() View Helper: Enabling Dojo for a page is not typically as
trivial as just loading the dojo.js script -- you have a
choice of loading it from the AOL CDN or a local path, and also may want
or need to load additional dojo, dijit, or dojox modules, specify custom
modules and paths, specify code to run at onLoad(), and
specify stylesheets for decorating dijits. On top of this, this
information may change from page to page, and may only be needed for
a subset of pages. The dojo() view helper will act as a
placeholder
implementation, and facilitate all of the above tasks, as well as take
care of rendering the necessary style and
script elements in your page.
-
Form Element implementations: One area that developers really
leverage javascript and ajax toolkits is forms. In particular, many
types of form input can benefit from advanced and rich user interfaces
that only javascript can provide: calendar choosers, time selectors,
etc. Additionally, many like to use client-side validation in order to
provide instantaneous validation feedback to users (instead of requiring
a round-trip to the server). We will be identifying a small group of
form elements that we feel solve the most relevant use cases, and write
Dojo-specific versions that can be utilized with Zend_Form.
(One thing to note: Zend_Form's design already works very
well with Dojo, allowing many widgets and client-side validations to be
created by simply setting the appropriate element attributes.)
-
dojo.data Compatibility:
dojo.data defines a
standard storage interface; services providing data in this format can
then be consumed by a variety of Dojo facilities to provide highly
flexible and dynamic content for your user interfaces. We will be
building a component that will create dojo.data compatible payloads with
which to respond to XmlHttpRequests; you will simply need to pass in the
data, and provide metadata regarding it.
Of course, you can continue to any Ajax library in conjunction with the Zend Framework, and ditto for Dojo.... but why did this match happen?
There are many synergies and similarities between the two projects and their communities, including:
- Licensing and IP: Both projects are very business friendly.
- Design affinity: Similar philosophies, including a strong emphasis on use-at-will architecture.
- JSON format used strongly in both
- Comprehensive Ajax Solution: Dojo has it all
- Standards: "Dojo not only implements published standards, but also drives them"
- Communities and support: Strong communities, with support offerings behind them
And, here is some code from a JSON-RPC demo:
PHP:
-
-
<h2>Dojo JSON-RPC Demo</h2>
-
<input name="foo" type="button" value="Demo" onClick="demoRpc()"/>
-
<?
-
$this->dojo()->setLocalPath('/js/dojo/dojo.js')
-
->addStyleSheetModule('dijit.themes.tundra')
-
->requireModule('dojo.rpc.JsonService');
-
$this->headScript()->captureStart(); ?>
-
function demoRpc()
-
{
-
var myObject = new dojo.rpc.JsonService('/json-rpc.php');
-
console.log(myObject.bar());
-
}
-
<? $this->headScript()->captureEnd() ?>
-
Thursday, March 6th, 2008
Category: Ext
, JavaScript
, PHP
I got emails on the same day from two developers letting me know about ExtJS wrappers for PHP.
PHP-Ext
First, Sergei Walter Guerra told me about PHP-Ext "an open source widget library written for PHP 4 and 5 to empower the UI Layer."
The API looks like this:
PHP:
-
-
-
Javascript::stm(ExtQuickTips::init()),
-
Javascript::assign("data",Javascript::valueToJavascript($myData)),
-
//Javascript::valueToJavascript($myData),
-
$store->getJavascript(false, "ds"),
-
$italicRenderer,
-
$changeRenderer,
-
$pctChangeRenderer,
-
$colModel->getJavascript(false, "colModel"),
-
$gridForm->getJavascript(false, "gridForm")
-
);
-
-
$gridForm = new ExtFormPanel("company-form");
-
$gridForm->Frame = true;
-
$gridForm->LabelAlign = EXT_FORM_LABEL_ALIGN_LEFT;
-
$gridForm->Title = "Company Data";
-
$gridForm->BodyStyle = "padding: 5px;";
-
$gridForm->Width = 750;
-
$gridForm->Layout = EXT_CONTAINER_LAYOUTS_COLUMN;
-
ExtPHP
Then Chris Ravenscroft came to me to announce ExtPHP:
"It is something that I had to think about in my day job, because my team is migrating to PHP for web development and I believe that we simply do not have enough time for them to learn JavaScript's intricacies, I needed to be the one person who would have to wrestle JavaScript when problems happened. I therefore needed a way to insulate them from the gory details, which is why I created ExtPHP."
The API looks like this:
PHP:
-
-
$cfg = new Ext_Viewport_Config();
-
$viewport = new Ext_Viewport(
-
$cfg->
-
layout('border')->
-
items(array($actionpanel,
$tabpanel->
name()))
-
);
-
$viewport->jsrender();
-
-
$tabpanel->add(
-
array('title'=>
'New Tab',
'iconCls'=>
'tabs',
'autoLoad'=>
-
array('url'=>
'extphptest.php?content1'),
-
'closable'=>true
-
)
-
);
-
-
new JsReady(JsWriter::get());
-
Maybe you guys can join forces? :)
3.1 rating from 108 votes
Thursday, February 28th, 2008
Category: JavaScript
, PHP
, Tip
My favourite kind of tutorial or trick are the ones that are very easy to do but make a lot of sense - you know the ones that make you slap your forehead and say "why didn't I do that before?".
Dirk Ginader blogged about a commenting trick (in German) that is one of these. He rightly claims that when you develop, you will comment and uncomment a lot as you optimise and test your code. This means either inserting lines with comment and deleting those lines, adding and deleting the /* */ by hand or using a shortcut of your editor of choice (I loved Homesite for ctrl+shift+m). In any case, it means highlighting several lines to comment in or out.
If you however use the following syntax then you only need to delete one slash to comment and uncomment a section:
JAVASCRIPT:
-
-
foo();
-
/*
-
bar();
-
baz.foo = 200;
-
return{
-
dolly:clone()
-
}
-
// */
-
The trick is the // before the closing */. With this you can just add another slash before the opening one and uncomment the block this way.
JAVASCRIPT:
-
-
foo();
-
//*
-
bar();
-
baz.foo = 200;
-
return{
-
dolly:clone()
-
}
-
// */
-
This works in many languages, alas not in CSS as there is no single line comment.
Update: in CSS you can just delete and add and remove an asterisk:
CSS:
-
-
.test{
-
border:1px solid red;
-
/*/
-
background-color:blue;
-
/**/
-
margin:1em;
-
}
-
CSS:
-
-
.test{
-
border:1px solid red;
-
/**/
-
background-color:blue;
-
/**/
-
margin:1em;
-
}
-
Monday, January 14th, 2008
Category: Library
, PHP
, Security
HTML Purifier 3.0 has been released.
What is HTML Purifier?
HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.
What's new in 3.0?
Release 3.0.0 is the first release of 2008 and also HTML Purifier's first
PHP 5 only release.
The 2.1 series will still
be supported for bug and security fixes,
but will not get new features. This release a number of
improvements in CSS handling, including the filter
HTMLPurifier_Filter_ExtractStyleBlocks which integrates
HTML Purifier with
CSSTidy for cleaning style sheets
(see the source code file for more information on usage), contains
experimental support for
proprietary CSS properties with %CSS.Proprietary, case-insensitive
CSS properties, and more lenient hexadecimal color codes. Also, all code
has been upgraded to full PHP 5 and is
E_STRICT clean for all versions of PHP 5 (including the
5.0 series, which previously had parse-time errors).
You can run a live demo to see it at work.
Thursday, January 10th, 2008
Category: Framework
, PHP
John Le Drew has been working on a PHP framework for a few years, and has now packaged it as Simplicity:
The Simplicity PHP Application Framework is an advanced, scalable and extensible PHP application framework to aid developers in creating high traffic, high availability Web 2.0 online applications. Integrating a solid MVC framework with some of the best Open Source projects around Simplicity aims to assist developers with any amount of experience in taking their applications to a new level.
You can get to the code on the launchpad for the framework.
One important piece is the Ajax admin console, developed in Ext that allows a developer will be able to configure all aspects of their application via the Ajax interface, this includes database modeling and the creation of stub controllers, and even the addition of predefined actions to speed up development.

Friday, July 20th, 2007
Category: Articles
, Gears
, PHP
, Prototype
Jack Herrington has written his second article in his series on Gears.
The article goes into detail on creating a form based data entry application that works offline. This means that entries are batched up, so when the user goes online they can be sync'd up. The forms are sent using Prototype and Ajax.Updater.
Jack iterates on the data model, going from a simple blog, to separate content.
Conclusion
For years now, web applications have been stuck at the 90 percent solution mark. Web applications are incredibly easy to develop, but fail utterly when the customer isn't connected to the Web. On the day Google Gears was released, I knew that this status quo had instantly changed. Just as the addition of Ajax functionality to the browser was the one small step that added rich interactivity, this small step of Gears solves one of the few remaining problems of web development. What a powerful tool indeed!

Friday, July 13th, 2007
Category: JavaScript
, PHP
I haven't seen many languages implemented in PHP. J4P5 "is a JavaScript interpreter written in PHP 5, that allows to run untrusted scripts in a sandbox on your server. It aims to implement most of Ecma-262 3d edition."
J4P5 uses a modified version of the CFG parser of the MetaPHP project, and is licensed under the GPL
This project is new. The current version already exposes most of the features commonly associated with JavaScript, such as objects, prototypes, closures.
Notable caveats of this version (aka "the TODO list"):
- No support for unicode strings
- No support for regular expressions
- Semi-colons at the end of statements are not optional
- Most of the pre-defined objects/methods have not been tested
- The speed is definitely slower than PHP. It's getting better though.
Monday, June 18th, 2007
Category: PHP
, jQuery
plainTemplate is a new library that aims to separate out an HTML template from design and coding, thanks to selectors.
The designer works by simply using HTML in any way they wish, and then the programmer:
- Write selectors based on HTML structure
- Pass those selectors and Controller data to plainTemplate
- plainTemplate parses template, removing designer's example data
- If there is a need, you can manually write template proccessing rules with phpQuery - a jQuery port to PHP
- Everything caches to pure, human-readable PHP file, similar to that one written with no template engine
- From one HTML file You can build several templates
- Once the Designer updates the file, the cached template updates itself transparently
phpQuery is a port of jQuery that let's you do things like this:
PHP:
-
-
_('body div.myClass.myClass2 ul> li:first')
-
->parent()
-
->prepend('<li>my new first LI</li>')
-
->parents('.myClass')
-
->remove()
-
->end()
-
->appendTo('body');
-
Download plainTemplate
Wednesday, May 9th, 2007
Category: Examples
, JavaScript
, PHP
Timothy Lorens has created a XAJAX PHP Live Datagrid that is as simple to setup as:
HTML:
-
-
<div id=“dataGrid†align=“centerâ€></div>
-
<script type=“text/javascriptâ€>
-
xajax_showDataGrid();
-
</script>
-
xajax_showDataGrid is a callback where you get to implement methods such as passing back how many rows there are, and the rows to show.

3.6 rating from 124 votes
Thursday, March 15th, 2007
Category: Library
, PHP
, jQuery
jQPie is a lightweight PHP interface to jQuery that supports XML, HTML and JSON handlers.
What can jQPie do?
- Easily request and process data from php using $.getJSON Example
- Inject php generated html into elements using $.(element).load Example
- Call php functions directly from your web pages using $.jqpie Example
- Call jQuery from php in respond to $.jqpie calls Example
- Advanced autocomplete using jqpie_complete ExampleAuto

Wednesday, March 14th, 2007
Category: Java
, Library
, PHP
, jMaki
The Sun Web Developer Pack isn't a sexy name, and having 'Sun' start it out often doesn't help a technology.... but there is some good technology here.
The Sun Web Developer Pack helps you to leverage emerging web technologies and techniques to create interactive and dynamic web applications for the enterprise. This toolkit is a collection of technologies for Ajax, Scripting and REST-based services development supported by a NetBeans plugin that simplifies the design and development of Rich Internet Applications.
If you look past the marketing-speak you see that Sun has packaged technology such as Project jMaki and Project Phobos.
jMaki is a lightweight, client/server framework for creating JavaScript-centric Web 2.0 applications. You can use jMaki when developing with PHP, Portlets, Facelets, Java, and JavaScript.
Do you see that? Since when did Sun create something that lets you develop with PHP :)
Phobos is a lightweight, scripting-friendly web application environment that runs on the Java platform.
Phobos allows you to write with JavaScript on the server side, which can be very powerful indeed.
There are a vast number of demos available including interesting mashups.

Wednesday, February 28th, 2007
Category: PHP
, jQuery
François Zaninotto has been talking about a new Unobtrusive JavaScript Plug-In for symfony.
Simple Example