Archive for the ‘php’ Category

{{macro}} online usage examples

Monday, March 3rd, 2008

Sergey Yudin(syfisher) did really great job by making {{macro}} template engine examples available on-line.

If you are wondering who in the world in his sane mind might need yet another PHP templating engine, well…I blogged about {{macro}} some time ago where, I hope, I presented some unique arguments in its favour. Here’s the quote from that post which, probably, most nicely and concisely describes the main idea behind {{macro}}:

To be short, the main idea behind {{macro}} is to use C/C++ alike(but way more sophisticated) macro tags to simplify usage of raw PHP in templates.

Ok, going back to the subject of this post, the mentioned page has runnable examples for mostly all core {{macro}} tags. You can browse the template rendering result page, template sources and PHP code which actually works behind the scene.

You can also download the source code of these examples from projects page(where, by the way, you can find some other real life Limb3 usage samples).

We are going to update examples on the regular basis presenting other interesting {{macro}} usage patterns in the future, so, if you are interested, stay tuned.

Update: Sergey also made a “Generated PHP code” link for each example, so it’s possible to view what PHP code is generated for each case. Cool stuff ;)

Limb3 2007.4(Frozzy) Released!

Monday, January 14th, 2008

Actually Limb3 2007.4 was released on the 31st of the December 2007 but we(here in Russia) have 10 days of official holidays and I simply was too lazy to blog anything during those crazy days of champagne-with-vodka-fest-and-early-morning-hangovers ;)

If you are wondering what Limb3 actually is and why world needs another PHP…er…framework(btw I hate this word too!), here’s a brief introduction. Limb3 is just a bunch of relatively independent packages, it is not a monolithic framework. Some packages are pretty unique(e.g {{macro}}) while others were inspired by cool stuff available for other than PHP platforms(e.g. active_record inspired by Rails’ ActiveRecord). And no, Limb3 was never intended to be “the one and the only one true PHP framework”. I personally believe in well thought code re-usability, thus the end application may contain bits of ezComponents, ZendFramework, PEAR, Limb3 and name-your-favorite-PHP-libraries-here.

Anyway, it’s better late than never, so here’s the list of the most notable changes made during past 6 months:

* ACTIVE_RECORD package: better invalid fields handling using
exceptions, support for different names of the primary key added
* CORE package: cruft cleanup, refactoring and misc. code
optimizations
* CACHE package: cleanup and better implementation, added
initial APC and Memcached support
* DATETIME package: major refactoring, renaming lmbDate into
lmbDateTime, etc
* {{macro}} alternative to WACT templating engine added with almost
all WACT alike functionality(and even more!)
* IMAGEKIT package: complete redesign using filters and fluent interfaces
* TESTS_RUNNER package: test groups and methods filters, better
coverage support
* JS package: upgraded jQuery to 1.2.1
* MAIL package: upgraded phpmailer to 1.73
* WEB_APP package: major cleanup, removed all commands and obsolete
controllers
* VIEW package: support for view selection based on template extension
added(currently MACRO and WACT)
* TREE package: ArrayAccess and ArrayIterator interfaces compatibility fixes
* FS package: more generic file system iterators added

Please note, this is rather a general changelog above, see the specific package changelog for more details.

The bundled release of all packages is available in the SourceForge downloads section of Limb3-2007.4

(more…)

A reliable way to serialize/unserialize objects in PHP

Monday, December 10th, 2007

An experienced PHP developer might be wondering why posting this topic in a blog if PHP already has universal and almost transparent tools for this job, specifically serialize and unserialize built-in functions.

The key statement here is “almost transparent” which means you have to include all class definitions before invoking unserialize or use some __autoload schema. Otherwise you are going to face the dreaded “The script tried to execute a method or access a property of an incomplete object” fatal error.

The whole problem is due to the fact a serialized object has no idea about its class definition except the class name(the reason behind that is absolutely valid).

(more…)

My “AOP in PHP” slides from secon-2007.11 conference

Monday, November 19th, 2007

AOPman Here are my Russian “AOP in PHP” slides from secon conference which took place on the 13th of the November 2007 in Penza, Russia.

Go grab it if you are interested in Aspect Oriented Programming in PHP or simply want to practice your Russian ;)

Automating packages upload for PEAR channels running Chiara_PEAR_Server

Monday, November 19th, 2007

Setting up Chiara_PEAR_Server with Crtx front end is a little bit confusing(even if you follow the official guide) but at least it happens just once ;)

Another important matter is maintaining your lovely PEAR channel up-to-date which, of course, assumes nice and easy way of uploading new packages. Actually Crtx’s web interface provides such a way and it works just fine for a couple of packages but if you have more than a dozen of them uploading new packages quickly becomes a boring process(e.g. we have 20+ packages at Limb3 PEAR channel)

That’s why I hacked up a script which automates this process quite a bit ;)

(more…)

Bug in Crtx_PEAR_Channel_Frontend?

Saturday, November 17th, 2007

I’m using Crtx_PEAR_Channel_Frontend-0.3.1-alpha as a PEAR channel front end and I’m pretty happy about it. However there seems to be a bug in the Crtx_PEAR_Channel_Frontend :: getPackageLatestReleases() method at line 500.

It reads:

unset($release[$states[$i+1]]);

While it should read:

unset($release[$states[$i]]);

I tried to email the original author Davey Shafik some time ago to no avail but at least now you are warned ;)

limb/tests_runner-0.8.7 released!

Saturday, November 10th, 2007

I’m glad to announce the new release of the limb/tests_runner package which reached 0.8.7-beta version! This package ships with limb_unit - a SimpleTest tests “swiss army knife” console based runner. If you’d like to know more about limb_unit utility I would highly recommend reading its documentation since it provides quite unique features like nested fixtures, code coverage and so on(documentation it’s actual for 0.8.5-beta as of this writing, but that’s ok).

This release introduces some unique filtering features which can be quite useful for large sets of tests. Now it’s possible to use filters for the following entities:

  • test classes
  • test classes’ methods
  • test classes’ PHPDoc @group annotation tags

In the rest of this post I’ll describe these new features in detail.
(more…)

{{macro}} - a zillionth attempt to make a PHP template engine that sucks less

Sunday, November 4th, 2007

After having used multiple template engines for the last 5 years I’m a strong believer that the best template engine is…PHP itself :) We just need some tools to make the usage of raw PHP in templates more friendly and readable.

I have used the forked version of WACT template engine for about 3 years and finally come to the conclusion that its runtime part is way too complicated and non obvious at times. However I do very like the idea of compile time tree of components which generate PHP code. At the same time I just wanted to simplify WACT and make the process of adding new tags much more straight-forward.

That’s why I have hacked up the initial implementation of {{macro}}. To be short, the main idea behind {{macro}} is to use C/C++ alike(but way more sophisticated) macro tags to simplify usage of raw PHP in templates.

(more…)

Buildman - dead simple Continuous Integration tool

Sunday, November 4th, 2007

If you have ever tried to setup the Continuous Integration process using one of the well known ‘classic’ tools like CruiseControl you might have been wondering if there’s a simpler and quicker way. I have been wondering too, thus meet Buildman ;)

(more…)

A couple of nginx utility scripts

Saturday, October 20th, 2007

In my previous nginx related post I promised to show a couple of utility scripts we use to simplify managing of multiple virtual hosts both under Apache and nginx. Well, here they come ;)

(more…)