Posts Tagged ‘PHP’

PHP support is a must

Friday, October 24th, 2008

Some minutes ago a new blog post by Bradley Holt popped up in my RSS reader. I admit that alone is no reason to write a blog post here, but the content of the Bradley’s post is worth doing it. ;)
Bradley tells us that the guys at Google plan to add support for a new runtime language in Google’s App Engine. So what’s the problem and what to do now? Bradley writes the following:

Looking at the issue list, support for Java is the most requested item followed by support for PHP, Ruby, then Perl. If you haven’t already, please go star the “support for PHP” issue (please don’t comment on it as it will email everyone who has already starred it - just star it!). Of course, I’m hoping Zend Framework is the framework of choice for all the App Engine specific APIs as well.


I already starred it and so should you!
Click here: To The Issue List

I needed some seconds to find the star, so here is a picture for the slower people like me. ;)

Apology, Zend Framework 1.6.2 and 1.7 Preview Release

Tuesday, October 14th, 2008

I’m really sorry that it got so quiet here for nearly two month. The first weeks of quietness were simply caused by my laziness but since mid of September I’m totally busy finishing a new php application for my company and the deadline is coming closer and closer every minute. It’s a bit like a vicious circle: I’m of course focussed on the project and even in my spare time it’s difficult to relax because my thoughts are most of the time with the problems, bugs or tasks I need to solve next day. So I’m getting even more stressed, that leads to less productivity which leads to more stress. Well, I guess you got the point. As you can see, I located the problem, but still it’s difficult to break the cycle.
However, if I look at my statistics, there are still some people out there who didn’t kicked me out of their RSS reader lists. Thanks for that. If you are not consuming the RSS feed but visiting my site, you probably noticed that I started restarted microblogging at twitter. Seems like I’m getting more and more Web 2.0 compatible (still unsure if this is a good thing ;) ). So basically the message of the first part of this blog post is: I’m back (even though I was never really gone).
Enough about me, let’s get to the news:

I got the announce email this morning: Zend Framework 1.6.2 is now available!
It is a bugfix release (check the changes here). I already updated my svn:externals properties and so should you.

And I got another announce email this morning: Zend Framework 1.7 Preview Release is now available!
It’s time for lunch, so let me just copy the changes in here from the email:

  • New Zend_AMF component
  • Dojo Toolkit 1.2.0
  • New ZendX_JQuery component
  • Support for dijit editor
  • Metadata API in Zend_Cache
  • Google book search API
  • Performance enhancements
  • Application-wide locale with other i18n enhancements
  • File upload form element enhancements

I’m especially curious about the performance enhancements and I’m looking forward to see some new “PHP Framework Speed Comparison Benchmarks” soon.

My Very First Steps with Zend_Dojo

Wednesday, August 20th, 2008

Even though I feel pretty tired this evening, I had to satisfy my curiosity and took a quick look at Zend_Dojo.

My first result: (Click on the picture to see the demo)

Looks quite nice. If you (like me) don’t know the Dojo Toolkit yet, you probably need some time to understand the documentation. It would have been easier to play around with Dojo independently from the Zend_Dojo stuff for some time, but as long as there is no time pressure on you, trial and error can be fun too. I simply tried to follow the Zend_Dojo documentation. First of all you need to tell the view object where it can find the Zend_Dojo ViewHelpers. I’m doing this in my bootstrap file (I’m using the default directory structure like it is described in the docs):

<?php
error_reporting(E_ALL|E_STRICT);
set_include_path('../library' . PATH_SEPARATOR . get_include_path());

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

$layout = Zend_Layout::startMvc();
// Tell the view where it finds Zend_Dojo ViewHelper
$layout->getView()->addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');

$front = Zend_Controller_Front::getInstance();
$front->addControllerDirectory('../application/controllers');
$front->throwExceptions(true);
$front->dispatch();

Next step is to include the Dojo library. Because this belongs into the <head> part of your HTML document, I’m changing my layout file (layout.phtml):

<?php echo $this->doctype() ?>
<html>
<head>
    <title>roetgers.org Dojo Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <?php
    // My own stylesheet
    echo $this->headLink()->setStylesheet('/css/my.css');
    // Check if dojo library is needed
    if ($this->dojo()->isEnabled()):
        // Include dojo library
        $this->dojo()->setLocalPath('/js/dojo/dojo.js')
            // Use dojo theme tundra
            ->addStyleSheetModule('dijit.themes.tundra');
        // Echo out the dojo <script> tags
        echo $this->dojo();
    endif; ?>
</head>
<!-- Set body class to "tundra" -->
<body class="tundra">
<?php echo $this->layout()->content ?>
</body>
</html>

After those changes my application is prepared to use Dojo. In the beginning of a view script you need to tell the ZF, that Dojo is needed by calling

$this->dojo()->enable();

If you don’t do this, the Dojo library will not be included in your layout.phtml file and Dojo won’t work. My first target was to create a TabContainer. Of course there is a ViewHelper which you can use to create such a container:

echo $this->tabContainer($id, $content, $params, $attribs);

Looks like a normal ViewHelper. But there is a difference because all layout containers know the capture methods captureStart() and captureEnd():

<?php
$this->dojo()->enable();

// Container with tabs
$this->tabContainer()->captureStart('tab1', array(), array('style' => 'width:800px;height:500px;'));
    // My content goes here
echo $this->tabContainer()->captureEnd('tab1');

I really like this way of adding content into a container, because your view script stays readable even if you start nesting containers into containers. Let’s have a look at my complete view script which I used for my sample:

<?php
$this->dojo()->enable();






// Container with tabs
$this->tabContainer()->captureStart('tab1', array(), array('style' => 'width:800px;height:500px;'));

    // First tab "Dates"
    $this->contentPane()->captureStart('pane1', array(), array('title' => 'Dates'));
        echo $this->form1;
    echo $this->contentPane()->captureEnd('pane1');
   
    // Second tab "FAQ"
    $this->contentPane()->captureStart('pane2', array(), array('title' => 'FAQ'));
        echo '<h1>FAQ</h1>
        <dl><dt>Question 1?</dt><dd>This is my answer 1!</dd></dl>
        <dl><dt>Question 2?</dt><dd>Good question, next one.</dd></dl>
        <dl><dt>Question 3?</dt><dd>Ok, that\'s enough!</dd></dl>
        '
;
    echo $this->contentPane()->captureEnd('pane2');
   
    // Third tab "Closable"
    $this->contentPane()->captureStart('pane3', array(), array('title' => 'Closable', 'closable' => true));
        echo 'You can close me!';
    echo $this->contentPane()->captureEnd('pane3');
   
    // Fourth tab "Splitted"
    $this->contentPane()->captureStart('pane4', array(), array('title' => 'Splitted'));
        $this->splitContainer()->captureStart('split1', array(), array('style' => 'width:250px;height:250px;'));
            $this->contentPane()->captureStart('splitpane1', array(), array());
                echo 'Hey, I am on the left side!';
            echo $this->contentPane()->captureEnd('splitpane1');
            $this->contentPane()->captureStart('splitpane2', array(), array());
                echo 'Cool!';
            echo $this->contentPane()->captureEnd('splitpane2');
        echo $this->splitContainer()->captureEnd('split1');
    echo $this->contentPane()->captureEnd('pane4');

echo $this->tabContainer()->captureEnd('tab1');

As you can see every tab is a new ContentPane. ContentPanes can be used inside every layout container except the AccordionContainer. Have a look at the docs for more information on that.
I’m displaying a form in the first tab. This form is an object of the class Zend_Dojo_Form. There are some really cool Dojo widgets (Dijits) which you can use to spice your forms up. The form is created in my IndexController:

public function indexAction()
{
    $form1 = new Zend_Dojo_Form();
    $form1->setMethod('post')->setAction("/");
    $form1->addElement('DateTextBox', 'date1', array(
        'label' => 'Choose a date:',
        'datePattern' => 'yyyy-MM-dd',
        'validators' => array('Date'),
        'required' => true
    ))
    ->addElement('TimeTextBox', 'time1', array(
        'label' => 'Choose a time:',
        'timePattern' => 'HH:mm:ss',
    ))
    ->addElement('NumberSpinner', 'number1', array(
        'label' => 'Choose a number:',
        'value' => 0,
        'smallDelta' => 1,
        'min' => 0,
        'max' => 30,
        'defaultTimeout' => 100,
        'timeoutChangeRate' => 100,
    ))
    ->addElement('HorizontalSlider', 'slide1', array(
        'label' => 'Let\'s slide:',
        'minimum' => 0,
        'maximum' => 25,
        'discreteValues' => 10,
        'style' => 'width: 450px;',
        'topDecorationDijit' => 'HorizontalRuleLabels',
        'topDecorationLabels' => array('0%', '50%', '100%'),
        'topDecorationParams' => array('style' => 'padding-bottom: 20px;'),
    ))
    ->addElement('SubmitButton', 'submit', array(
        'label' => 'Submit!'
        ));

    $this->view->form1 = $form1;
}

As you can see it is ridiculous easy to put together such a form. Basically it is the same as with the normal Zend_Form. Of course the Dojo form elements have different names (e.g. “SubmitButton” instead of “submit”) and you need some additional array keys in the form element configuration but then the magic happens.

This is only the very first step on my way of understanding Dojo but so far it looks promising! I’ll write more about it as soon as I digged deeper into that topic.

Link to My Demo

Bookreview: php|architect’s Guide to Enterprise PHP Development

Saturday, August 16th, 2008

\"php|architect\'s Guide to Enterprise PHP Development\" Book CoverDespite the fact that I ordered the book on the 25th of June, I finally received my copy last Saturday. The postal service can’t be blamed. They needed five days from Cincinnati, Ohio to Wildeshausen, Lower Saxony (Germany). From my own experience that’s quite good. I don’t know what happened in the meantime, maybe too many people preordered the book. However, I found some hours of spare time in the last days to read the book.

Before I’ll go into detail, let me give you a short summary. Ivo Jansch (that’s the author by the way) describes the audience of the book on the back as follows:

Whether you are running a large scale web app in a PHP-based environment, or if you are considering switching your site to PHP, php|architect’s Enterprise PHP Development will surely be a valuable resource for you and your development team.

I partly disagree. I’ll explain that later. The book tries to tackle everything which is related to enterprise PHP development. From building the team through software architecture to maintenance. Because of the wide range of topics and only 265 pages available, things cannot be discussed in detail. Most of the time that works, sometimes it does not.

The book starts with PHP’s background. Ivo talks about its history and discusses pros and cons. If you’re relatively new to PHP, those two chapters are very valuable. All important aspects get mentioned. If you already work with PHP for some time, you can skip them.

After chapter 2 the main part entitled “Enterprise Development” begins. Ivo starts by talking about The Team. Different roles in a team, training and recruitment are the covered subjects.

The chapters 4 and 5 deal with how to Gather Requirements and how to do the Planning. If your boss should ever come to your office and tell you that you’re going to talk to the new customer about the features the new software should have, read chapter 4. It lists all kinds of requirements which should be defined together with the customer. If you rarely talk with customers, it will help you to touch all important subjects in the meeting.
If you are a developer, you probably know the following situation: You are discussing with someone about a new feature which should be added to a software. You clarified all requirements and details, the meeting draws to a close and then your counterpart asks the final question: How long does it take to finish the task? The bigger the task, the harder it is to do a correct estimation. Personally I find it pretty difficult to pre-estimate the needed time correctly. Chapter 5 talks about exactly that.

So far I was entirely satisfied with the book and chapter 6 with the title Architecture sounded interesting but in my opinion Ivo chose the wrong topics here, namely OOP, UML and Design Patterns. Every PHP book, which covers slightly advanced topics, explains me in detail how to use abstract classes, interfaces and the singleton pattern. Such stuff doesn’t belong in this book! So after reading something about constructors and iterators, I arrived at the heading Enterprise Patterns. Cool! The topic lasts half a page. Uncool! Ok, that was somewhat disappointing but Ivo saves the situation by talking about Database Design. Of course you have to read about some basic stuff like relationships but there is also a big (”big” in the context of this book) ORM part which turned out well. The chapter closes with High Level Architectures (MVC, Multi-tier Development, SOA). Talk more about that in the 2nd edition of the book please. ;)

Chapter 7 is about Tools. In there you find some very obvious wisdoms like your editor should support syntax highlighting but also some important things like Source Control.

Chapter 8 - Building Blocks. That chapter is about 3rd party software. That means CM software, eCommerce solutions, frameworks and similar stuff. Difficult topic, because, whatever you’re saying, you directly steer into religious conflicts between the different frameworks, forums or libraries. Ivo solves this pretty good by praising all of them equally. ;)

Chapter 9 is about Security and I experience the second letdown. The chapter starts by telling me

Don’t Trust Input

Oh really? And htmlspecialchars() converts special characters to HTML entities? Neat! What was the main topic again? Oh yeah … enterprise PHP development. Fortunately Ivo enhances the chapter later by talking a bit about OpenID and ACLs.

Chapters 10-16: Development, Quality Assurance, Optimization, Deployment, Implementation, Operations, Maintenance. No, I’m not running out of time. Ivo, great job! Lots of enterprisish things in here. He covers many interesting topics like the different kinds of testing (he even mentions TDD and Continuous Integration), caching, clustering, monitoring and change management. And there is a lot more in these chapters.

In the end Ivo invests 10 pages in Development Methodologies and Project Management. A good ending which strengthens the positive overall impression.

Conclusion: First of all some thoughts about the audience. Remember the quote in the beginning?

Whether you are running a large scale web app in a PHP-based environment, or if you are considering switching your site to PHP, php|architect’s Enterprise PHP Development will surely be a valuable resource for you and your development team.

If I’m running a “large scale web app”, I don’t need this book because I know nearly everything about that stuff. Otherwise my “large scale web app” will crash in 3, 2, 1, now! I would recommend this book to

  • PHP hobbyists, who want to become professional developers
  • junior developers, who are in their first year on the job and
  • more experienced developers, who have to put together their first team

I think I clearly exposed the parts I disliked but all in all it is a great book! It offers loads of interesting information and exciting subjects to think about. If you count yourself to one of the above mentioned groups of people, give the book a read. If you are more experienced, you can still read the book in order to verify that you know all the important stuff.

Zend Framework 1.6 RC2 available

Monday, August 11th, 2008

The second 1.6 Release Candidate was published earlier this day and - wow - we’re going to get a lot of new stuff to play with. Or like Matthew put it:

There are a ton of new features available that I’m really excited about.

Word! ;) Not only that the Zend Framework is getting more mature with every release, it’s growing unbelievably fast. I didn’t expected such a fast evolution when I started evaluating it (I guess it was version 0.92 back then).

When it comes to Javascript I’m using the Prototype/script.aculo.us combination because I already know it from RoR but I skipped through the Zend_Dojo docs and Matthew wrote a bit about the Dojo integration and I have to admit: the new Zend_Dojo stuff looks promising! I’m really thinking about dropping Prototype/script.aculo.us in favor of Dojo. I’ll write a report as soon as my evaluation process brought out some perceptions.

Next new big thing is of course Zend_Soap. It is mandatory for a modern web framework to have a SOAP component. Even though none of my active projects is using SOAP in any way (REST is all over the place nowadays), the availability of Zend_Soap let me sleep a bit better. There is a feature called Zend_Soap_Autodiscover which looks interesting. I’ll dig into that later that week, hadn’t had the time yet to do so.

Thomas finished his Zend_File_Transfer component. I already tested the component out of the trunk. I’m extensively using Zend_Form in some of my applications and this was the last piece which I really missed regularly when I worked with forms.

Besides my top 3 there are of course many other new components like Zend_Paginator (I didn’t test the component yet, but it looks helpful), Zend_Test_PHPUnit with which you can test the MVC part of your applications (I already used an earlier version from SVN, it’s very easy to work with) and Zend_Text_Figlet which is … interesting. ;)

A big Thank You to all Zend Framework Contributors out there in the world. I seriously never enjoyed it more to develop PHP applications!

(more…)

Zend_Acl Quickstart

Saturday, August 9th, 2008

This screencast covers the usage of Zend_Acl in combination with Zend_Auth. Zend_Acl will be used to implement a static “Access Control List” in the existing sample application which was created in the Zend_Auth screencast. At the bottom of this page you find the sources and relevant links.

 
icon for podpress  Zend_Acl Quickstart Screencast [30:46m]: Play Now | Play in Popup | Download

Screencast licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.

Zend_Acl Screencast available

Saturday, August 9th, 2008

As announced in my last blog post, I’m publishing today the second part of my Zend_Auth/Zend_Acl screencast series covering the usage of Zend_Acl. In this tutorial I’m showing how to build a static “Access Control List” and how to integrate it with the help of a plugin into an existing application.
I’ve used this way of implementing Zend_Acl some month ago on a medium-sized but simple CRUD user interface as a part of a bigger web application. So what I’m showing here is not just theory but capable for small or even medium real life projects. Maybe I will do a third screencast or write a tutorial which shows some advanced stuff like how to dynamically create and modify access control lists with the help of a database and how to cache the whole thing.

For now, enjoy the screencast.

Zend_Auth Screencast online

Thursday, August 7th, 2008

It’s a pleasure to annouce the availability of my first Zend Framework screencast in English.
My german Zend_Auth/Zend_Acl screencast got some very positive feedback over the last month, therefore it was quite obvious to create a revised english version of it. I have splitted it into two parts:
First part covers a simple Zend_Auth example with a database table as backend.
The second part brings Zend_Acl into the game with a static Access Control List.

Enjoy the screencast. Second part will be published within the next two days.

Zend_Auth Quickstart

Thursday, August 7th, 2008

This screencast covers the basic usage of Zend_Auth and Zend_Auth_Adapter_Dbtable. At the bottom of this page you find the sources and relevant links.

 
icon for podpress  Zend_Auth Quickstart [17:17m]: Play Now | Play in Popup | Download

Screencast licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.

German Zend_Auth/Zend_Acl Screencast

Thursday, August 7th, 2008

Als Basis für den Screencast wurde das Zend Framework in der Preview-Version des 1.5er Zweiges eingesetzt. Die dort besprochenen Möglichkeiten sollten also mindestens für die Lebenszeit 1.5er Reihe funktionieren.

 
icon for podpress  German Zend_Auth/Zend_Acl Screencast: Play Now | Play in Popup | Download