php developer

› DevShed: Generating View from MySQL to Simulate the Model-View-Controller Schema in PHP

DevShed has posted part three in their "Simulating the Model-View-Controller Schema in PHP" series today, this time focusing on the last of the three, the View.

All right, after refreshing the topics covered previously, as well as clarifying some key concepts with reference to the concrete subject of this series, this journey will continue by constructing yet another practical example to expand your overall knowledge of object-based programming with PHP. In particular, it's designed to show you to use a MVC-driven relationship in another real-world situation.

If you're wondering to what other cases this relationship can be specifically applied, then I have good news for you. In this final article, I'll show you how to implement the MVC schema, in order to generate different outputs (or views) from a given MySQL data set.

They start over with their code, generating a new schema based around a MySQL processing class. The controller pulls its information from the database (our model) as to how the results should be displayed. Next they describe the model to help interface with the actual table and finishing it off with the output class, resulting in either XML or plain-text output of the user information.

21/08/2006 3:46 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Nefarious Designs: Object-Oriented PHP Part 1: Definition

On the Nefarious Designs blog today, there's part one of a new series taking a look at the object-oriented functionality in PHP.

Following on from my posts "Object-Oriented Concepts" and "Object-Oriented Javascript", I'm going to take a look at OOP in PHP.

Having spent the last few months writing this tutorial, I've realised that it's far too long for a single post; so to I'm splitting it into several to make it easier to digest.

In this first part, he just looks at the definition of what objects are, what classes are, working with properties, the constructor, and more. Looks like the start of another great series.

21/08/2006 3:26 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› PHP-Tools Blog: New releases of patTemplate and patForms

Stephan Schmidt has posted a new update to the PHP-Tools blog today converning new releases of patTemplate and patForms.

After I finally finished my book (and my contribution to Exploring PHP) I finally have enough time to work on all of my open source projects again and today made two new releases. patTemplate 3.1.0b1 contains tons of changes since the last stable version. Most of the features that users have been requesting for years have been incorporated into this release, like the possibility to read templates from a database

The other release mentioned is for patForms 0.9.b3 containing lots of bug fixes and features to work with the PEAR installer.

20/08/2006 6:40 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Derick Rethans' Blog: Overloaded properties (__get)

Derick Rethans talks about something he noticed when working with backwards compatibility to PHP 5.1 for the eZ components project - the first of which is that __get doesn't behave itself in some situations.

The first issue is an extra notice in some cases. In our (ezcMailTools) class we implement a method that allows you to "reply" to a parsed e-mail message. you can see we loop over one of the seemingly public variables of the $mail class. However, the ezcMail class does not have this as a public member variable, but instead uses overload.

This all works 'fine' with PHP 5.1, however with PHP 5.2 the following notice was generated for this code:

Notice: Indirect modification of overloaded property ezcMail::$to has no effect in ../Mail/src/tools.php on line 364

The reason for this is that __get() only returns variables in read mode, while foreach() wants a variable in read/write mode as it tries to modify the internal array pointer. As it can't do this PHP 5.2 will now throw a warning on this.

The mentioned code examples are included and he includes the work-around that he found to help keep the issue from popping up again.

19/08/2006 10:29 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

derick rethans

› Overloaded properties (__get)

While checking whether the eZ components would run with the latest PHP 5.2 release candidate we noticed that there are some things that are not backwards compatible with PHP 5.1.

The first issue is an extra notice in some cases. In our (ezcMailTools) class we implement a method that allows you to "reply" to a parsed e-mail message. In this method we have the folowing code:

static public function replyToMail( ezcMail $mail )
{
// ...
    foreach ( $mail->to as $address )
    {
// ...
    }
// ...
}

As you can see we loop over one of the seemingly public variables of the $mail class. However, the ezcMail class does not have this as a public member variable, but instead uses overload as you can see in this code snippet:

public function __get( $name )
{
    switch ( $name )
    {
        case 'to':
            return $this->properties[$name];
    }
}

This all works 'fine' with PHP 5.1, however with PHP 5.2 the following notice was generated for this code:

Notice: Indirect modification of overloaded property ezcMail::$to has no effect in ../Mail/src/tools.php on line 364

The reason for this is that __get() only returns variables in read mode, while foreach() wants a variable in read/write mode as it tries to modify the internal array pointer. As it can't do this PHP 5.2 will now throw a warning on this.

There is a workaround however in the form of casting it to an array. After our changes the code now looks like:

public function __get( $name )
{
    switch ( $name )
    {
        case 'to':
            return (array) $this->properties[$name];
    }
}

The second issue is related to this. In this case we did not see an extra notice but instead a fatal error:

Fatal error: Cannot assign by reference to overloaded object in .../trunk/Url/src/url.php on line 242

The code around this line is:

if ( array_key_exists( $index, $this->path ) )
{
    $this->path[$name] =& $this->path[$index];
}

In this case $this->path is also an overloaded property returning an array. Because __get() returns a read-only variable assigning a reference can not work as that requires a variable to be in read/write mode. Most likely the code didn't work properly in PHP 5.1 either but luckily this is still in an unreleased component. However, I am not aware of a work-around here.

19/08/2006 6:34 pm (UTC)   Derick Rethans   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Elizabeth Smith's Blog: I guess I'm just ahead of the times...

On "Dreaming of Dawn", Elizabeth Smith has posted some of her own impressions of the Komodo editor following on the heels of this blog post from Clay Loveless.

When perusing php-planet today (or is it planet-php and why can't I ever remember?) I ran across an interesting article about changing from zend studio to komodo.

The amusing thing for me is I've been using komodo since 3.0 came out - in July of 2004. I'd gone through the whole list of php editors looking for two things - working debugging and code intelligence (e.g. tell me whether it's needle haystack or haystack needle - so damn annoying) At the time, the ONLY one with a working debugger for php 5 was komodo - ding ding ding we have a winner.

She goes on to talk about some of the other features she finds particularly helpful, including a toolbar to help with adding phpDocumentor-styled comments to her code and the SVN and CVS integration.

She does note one bad thing she's found about it - since it's Mozilla based, some of that browsers bugs just might poke through when developing. Despite that, though, she's been enjoying and will continue to enjoy what she thinks is one of the best editors out there (with a debugger, of course).

18/08/2006 2:02 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Evert Pot's Blog: Creating a Gopher server with PHP and InetD

New from Evert Pot today is this new post on his blog taking a look at the creation of a Gopher (you remember Gopher, right?) server with the help of PHP and InetD.

A long time ago, in the early nineties Gopher was the prefered way to access internet content.. Only later on Tim Berners Lee's HTTP/WWW idea took off. Sixapart recently wrote an article about this chapter of ancient internet history.

This tutorial will teach you how to create a Gopher Server using InetD with PHP. This will teach you how to create a simple socket server using InetD and it will teach you something about the gopher protocol.

He talks more about what Gopher is, what IntD is, and the things you'll need to get started on this quick trip. The script will run on the command line via InetD, setting it up to be able to be telneted into. They include a basic example of the Gopher protocol as well as a link to a class that will help parse and respond to the requests.

It's quick and simple, but it's a good starting point for anyone looking to set up their own Gopher server with PHP in a short amount of time.

18/08/2006 12:38 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› IBM developerWorks: Kick-start takes you to the movies (Part 1)

IBM's developerWorks section has started off a new series today with part one of their "Kick-start takes you to the movies" series focusing on using DB2 and PHP to create a personal movie database application.

Explore PHP and XML development using the Eclipse IDE, DB2 Express-C 9, and WebSphere Application Server Community Edition. Learn how to install and configure these applications, part of a program designed to kick-start your application development, to develop a Web-based movie information database. This is part one of a two-part tutorial, covering the installation and configuration of the tools, along with some basic proof-of-concept code development.

You'll need the Eclipse IDE and a web server with PHP and DB2 installed to follow along with this part, but once those are in place, the rest is smooth sailing. They walk you through each step of the way - setting up the XML database, creating your project, creating all of the database tables, and connecting your PHP to the database.

18/08/2006 3:41 am (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Tobias Schlitt's Blog: Free eZ components sessions -2- [Update]

Tobias Schlitt has an update posted today about the free eZ components sessions that were previously announced concerning the dates.

forgot that Wolfgang and me moved the dates for the sessions, because Wolfgang is on vacation and wants to take part in the sessions. Sorry for that! So, here are the correct dates:

The first session will now be held on September 20th and the second on September 22nd.

You can find out more about these sessions and about the other offerings from the DynamicWebPages training offerings from their main page.

17/08/2006 2:37 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

php developer

› Dikini.net: Rewriting macros - the peculiar case of php

On Dikiki.net today, there's a new post that's a continuation of a series (first post, second post) dealing with macro programming in PHP.

Without going into theoretical details, some of which are quite alien to me, I'll try to describe some of the challenges that pattern patching rewriting macros might pose for a language like php. After brief explanation what kind of a beast is this, I try to explore some of the finer points, which might cause problems. The intent of this post is to sketch a design and highlight some of the possible issues.

He breaks up the post into a few sections:

  • pattern matching rewrite only macros - a bird eye view
  • Transformation time
  • Basic/skeleton shapes and intermediate shapes
  • Code generation issues specific to php
  • Hygiene
  • A rough macro shape outline
  • Output/Status of the project
There are code examples (of how it should work) and explainations of the issues PHP would face to accomplish this goal.

17/08/2006 2:29 pm (UTC)   PHP Developer   View entry   Digg!  digg it!   del.icio.us  del.icio.us

eZ publish™ copyright © 1999-2005 eZ systems as