Phalcon 2.0 Alpha Landing

Posted by Unknown on Sunday, January 19, 2014

I’ve written about Phalcon before, and we’ve got a variety of articles on the framework published already, which is apparent if you just visit the Phalcon category. In fact, not so long ago, I wrote about Zephir, Phalcon’s noble initiative to make building PHP extensions accessible to everyone.


Today, a new milestone has been reached by the team, and one that definitely warrants discussion. Way ahead of time, the Phalcon team announced the imminent release of Phalcon 2.0 alpha 1.


Phalcon 2


Phalcon 2 is a full rewrite of the original Phalcon Framework, in their new language, Zephir. As previously discussed, Zephir is a mixed-type derivative of PHP (both static and dynamic types are supported) which allows developers to write “almost-PHP” code and compile it down to C based extensions for PHP, installable like any other (iconv, imap, imagick, etc). Phalcon 2 was built almost entirely in this language, and is now easier than ever to maintain, update and above all – accept contributions from the community. As proof of working concept, the Phalcon team is running their site on Phalcon 2 here.


Phalcon 2.0 is being brought up to speed with the current version 1.3 (it introduced some optimizations not present and yet required in 2.0), and is being built around existing 1.3 classes to ensure backwards compatibility. To see which classes were ported so far, observe the following table. If you’d like to assist in the transfers, submit a pull request as you see fit – particularly unit tests. Most of the ported components simply haven’t been tested yet, even after being fully developed.


Zephir and creating extensions


Zephir is now in version 0.3, and can be used by the general public to write custom extensions for PHP. Zephir supports all the standard logical structures you’re used to (except “else if”), and lets you pre-declare variables by type to make it easier to compile into highly optimized C code. It’s important to note that Zephir is an ahead-of-time compilation language, meaning the compilation step might just make you less productive if you’re used to iterating and testing rapidly. The long term gains, however, are worth it.


Zephir is memory-safe, meaning it has no pointers or manual memory management support. For such low level operations, one should stick with C. With regards to power, Zephir is thus weaker, but more user friendly than C. You can consider it a hybird of C and PHP, leaning more to the PHP side of things.


So what can I do with it? Always wanted to close-source your PHP app? Wondered how much faster a statistics calculation of your company’s backend would be if it were running in C? You can do all that and more now. First, check out this Vimeo screencast on making your first Zephir extension.



Creating your first PHP extension with Zephir from Phalcon Framework on Vimeo.


Next, follow through the tutorial, read the docs, and play around. If you end up making anything other than what the tutorials teach, we’d love to publish your step-by-step.


An example Hello World class like this one:



namespace Test;

/**
* This is a sample class
*/

class Hello
{
/**
* This is a sample method
*/

public function say()
{
echo
"Hello World!";
}
}


Truncated by Planet PHP, read more at the original (another 5614 bytes)




more

{ 0 comments... » Phalcon 2.0 Alpha Landing read them below or add one }

Post a Comment

Popular Posts