AnnoLoader beta release

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

AnnoLoader beta release

Post by VladSun »

http://code.google.com/p/annoloader/sou ... nnoLoader/

The problem

I have a lot of JS and CSS files needed to be loaded in a specific order based on their dependencies. I.e. an Ext.ex.grid.Panel extends the Ext.grid.Panel, so I need to load Ext.grid.Panel.js prior Ext.ex.grid.Panel.js in my HTML page. I have similar problems with CSS files - "overriding" styles should be loaded after the "original" ones.

The solution

I use PhpDoc like annotations in files that have some requirements. E.g.:

Ext.ex.grid.Panel.js

Code: Select all

/**
 * @annoloader-requires-file /Ext/grid/Panel.js
 */
In general I may have:

Code: Select all

/**
 *
 * @annoloader-requires-file 1.js
 * @annoloader-requires-file 2.js
 * 
 * @annoloader-requires-class Ext.Namespace.Class1
 * @annoloader-requires-class Ext.Namespace.Class2
 *
 * @annoloader-requires-namespace Ext.Namespace
 *
 * @annoloader-requires-directory ex/grid
 *
 * @annoloader-requires-directory-tree ex/data
 *
 */
Aliases:

Code: Select all

/**
 * the same as annoloader-requires-file
 * @annoloader-after-file /Ext/grid/Panel.css
 */
Critique needed on

1. PhpUnit tests applied (AnnoLoader_Dependency_Builder_ListTest needs more testing, but I'm not sure I do it right)
2. Patterns used
3. Decoupling

TODO

More complex caching


Thank's !!!
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: AnnoLoader beta release

Post by VladSun »

Anyone? :(
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Zyxist
Forum Contributor
Posts: 104
Joined: Sun Jan 14, 2007 10:44 am
Location: Cracow, Poland

Re: AnnoLoader beta release

Post by Zyxist »

It would be very helpful to post some examples from the PHP side, because just annotations show almost nothing, at least for me, and I could not find any examples on the project website. In addition, I think you should use PHP 5.3 namespaces, instead of the old underscore notation. More and more projects adapt it, and so should you.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: AnnoLoader beta release

Post by VladSun »

There is one simple example - the index.php file in the root directory
http://code.google.com/p/annoloader/sou ... /index.php

It will load all JacaScripts located in '/www/site/annoloader/scripts/test/AnnoLoader/js/ux' in order that would satisfy dependencies between them.

Another a little more complicated example:

Suppose we have:

[syntax]scripts/
/ex
/grid
Panel.js
/ux
/grid
Panel.js[/syntax]

Code: Select all

$js = new AnnoLoader_Facade_JS
(
        '/www/site/annoloader/scripts/test/AnnoLoader/scripts',
        array
        (
                'Ext.ex'        => 'ex',
                'Ext.ux'        => 'ux',
        )
);

$js->output(true);
exit();
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply