2009-07-04(土)
On PHPFreaks.com they have a new "top ten" list of signs to look out for to tell if you're dealing with crappy software or not.
Like it or not, as a professional developer, sooner or later you are going to do some customising (if you are lucky, "extending") of existing software. If you are not familiar with the software, it is good advice to look into it before accepting the job. I had to learn that the hard way. But how do you recognize crappy applications without getting knee deep into the code?
Their list of signs include:
- The software tries to reinvent the object model, or "fix" language features.
- Scattered HTML and SQL
- Multiple levels of inheritance
- In the code base, there is a directory called "core"
The PEAR blog has a quick note for users of PHP 5.3 and Windows:
Some users have reported that the windows builds of PHP 5.3 are not able to open the shipped go-pear.phar file.
If this is your situation, you can use their workaround (run the distributed phar version) or grab the non-pharred version.
Lorna Mitchell has posted the last article in her look at web services - a focus on status codes.
Unlike the other posts in this series, this one is quite specific to one type of service - REST - since it deals with status codes, specifically HTTP ones. The ideas are transferrable however and other types of service can return statuses in a similar way.
She mentions things to keep in mind in returning the codes, some of the more interesting codes as well as some typical situations where things like an error code 500 would be thrown.
Status codes are like a headline to the calling entity about what happened, and are a valuable tool in the web service toolkit.
Released at Fri, 03 Jul 2009 20:02:25 GMT by mundaun
Includes files: dummy-4.2.8.tar.gz (9380 bytes, 0 downloads to date), typo3_src-4.2.8.zip (9626687 bytes, 0 downloads to date), dummy-4.2.8.zip (20300 bytes, 0 downloads to date), typo3_src-4.2.8.tar.gz (8150235 bytes, 0 downloads to date), typo3_src+duk-4.2.8.zip (9684598 bytes, 0 downloads to date)
[Download] [Release Notes]
Released at Fri, 03 Jul 2009 19:54:20 GMT by mundaun
Includes files: dummy-4.1.12.zip (20350 bytes, 0 downloads to date), typo3_src-4.1.12.zip (8751990 bytes, 0 downloads to date), typo3_src-4.1.12.tar.gz (7581007 bytes, 0 downloads to date), typo3_src+duk-4.1.12.zip (8800665 bytes, 0 downloads to date)
[Download] [Release Notes]
John Lim has written up an article for the Oracle Technology Network about creating high performance systems with Oracle's Real Application Clusters (RAC) and PHP.
Running a software application that is able to work reliably through hardware and software failures is incredibly hard. [...] In this article, I will cover the network, architecture and design of our RAC application. Then I will discuss the real-world experiences and problems we experienced.
He details their RAC setup - load balancers, application servers and their RAC servers - before working through the different technologies and how they're all installed and configured to work together most efficiently.
2009-07-03(金)
In the next to last article of their loader series, DevShed looks at replacing some of the file loading functionality in their examples with functions from the SPL.
As I mentioned before, the Standard PHP library comes bundled with some helpful functions, such as "spl_autoload()," "spl_register_extension()" and "spl_autoload_register()" that allow you to either use a default implementation of the "__autoload()" function, or create a custom one for it.
Their example defines the extensions to use for autoloading and the name of the file/class to pull in. The rest is done automagically.
The day started with a nice movie made by Almer and Norman after which Cal officially opened the Dutch PHP Conference and introduced Andrei Zmievski to do the opening keynote. Andrei gave an outline of developments in PHP including the changes we are going to see in future versions. Closures, namespaces, better garbage collection and a few more things are coming to PHP5.3, but I think this isn't new to most people. I haven't really read a lot on PHP6 yet other than Unicode, so the addition of traits, C# style getters and setters and scalar/return value type hinting were new to me. I think this was a nice talk to be the opening keynote, because other than just being infomrative the talk also had the right amount of humor with some examples of frustrated people reporting "bugs" and a setting for y2k compliance. I wasn't active in PHP 10 years ago, but it made me laugh when I heard that the y2k_compliance setting basically did nothing other than stop people asking about it.
Continue reading "DPC 2009 Day 1"
- Community News: PHP Group Responds to Google's "Speed Tips" Recommendations
- PHP 10.0 Blog: PHP performance tips from Google
- SitePoint PHP Blog: A Note on Google's So-called Best Practices
- php|architect Blog: Confessions of a Hiring Manager: Get my attention, Get a Job
- NETTUTS.com: Easy Development With CodeIgniter
- Make Me Pulse Blog: Connect to Active Directory LDAP with PHP
- Zend Developer Zone: Accepting Credit Card Payments with OXID eShop CE and Authorize.Net
- Paul Jones' Blog: Scalable Internet Architecture
- PHP & jQuery: Calendars
- Stefan Mischook's Blog: PHP Video: Controllers in MVC
My article on High Performance and Availability with Oracle RAC and PHP is out on the Oracle web site. Enjoy.
![]()
Released at Fri, 03 Jul 2009 09:53:13 GMT by mschering
Includes files: groupoffice-com-3.02-stable-3.tar.gz (6102444 bytes, 0 downloads to date)
[Download] [Release Notes]
The website: http://conference.phpnw.org.uk
Tickets: http://conference.phpnw.org.uk/register. Early bird pricing until September 11th, student tickets available - look on the website for instructions on getting student tickets.
Call for Papers: http://conference.phpnw.org.uk/callforpapers. Speakers wanted! If you have something to share and you think you can do that coherently - then submit to us please, we're always looking for new people, new talks, as well as the talks and speakers you'd expect to see at the bigger PHP conferences. If you're not sure if something fits, feel free to contact us.
This is officially a one-day Saturday event, with a full day with two tracks of talks and an attendance of 200+ people. In reality its a whole weekend of geeking out in Manchester - with a pre-conference social on Friday night, the main event on Saturday, a conference social running on Saturday night and an informal set of sessions on Sunday morning for anyone with the energy to keep on going before everyone makes tracks to their homes.
If you're going, thinking of going, went last year, or wishing you could be there - add a comment! I'm looking forward to meeting many of you at the event :)
If you google it, you will probably find the quite definitive answer at mysql.com, describing the classic parent_id method, and the left/right numbering process. Both of these methods involve rather complex SQL to fetch and update the tree.
In seeking a better solutions for a tree that was infrequently updated, but frequently queried, I thought I'd try seeing if I could write a few stored procedures to simplify the process.
Our basic database structure looks like this:
CREATE TABLE _TREE_ (our key components are
id int(11) NOT NULL auto_increment,
parent_id int(11) NOT NULL DEFAULT 0,
seqid int(11) NOT NULL DEFAULT 0,
depth int(11) NOT NULL DEFAULT 0,
leaf int(1) NOT NULL DEFAULT 0,
name varchar(128) default '',
fullpath TEXT default '',
PRIMARY KEY (`id`),
INDEX qlookup( parent_id , seqid , depth)
);
- id (the nodes id)
- parent_id (the nodes parent - pretty clasic)
- name (the textual name of the node)
- seqid - the generated order item for the whole tree
- depth - how deep the node is (usefull for indenting)
- leaf - is it a leaf node (eg. has no children) - usefull for icons
This does the hard work of iterating through the tree, and updating the sequence number, depth, leaf field and filling in the fullpath field
DROP PROCEDURE IF EXISTS _TREE__resequence;
DELIMITER $$
CREATE PROCEDURE _TREE__resequence(i_sep VARCHAR(4)) DETERMINISTIC
BEGIN
DECLARE v_p, v_d, v_s INT(11);
DECLARE v_fp TEXT;
SET v_fp = '';
SET v_p =0;
SET v_d =0;
SET v_s =0;
SET max_sp_recursion_depth=255;
CALL _TREE__resequence_sub(v_p, v_d, v_fp, i_sep, v_s);
END $$
DELIMITER ;
DROP PROCEDURE IF EXISTS _TREE__resequence_sub;
DELIMITER $$
CREATE PROCEDURE _TREE__resequence_sub(
i_parent INT(11),
i_depth INT(11),
i_fullpath TEXT,
i_sep VARCHAR(4),
INOUT i_seqid INT(11)
) DETERMINISTIC
BEGIN
DECLARE v_nid, v_ex_seqid INT(11);
DECLARE v_name VARCHAR(128);
DECLARE v_leaf INT(1);
DECLARE v_fullpath TEXT;
DECLARE done INT DEFAULT 0;
DECLARE qry CURSOR FOR SELECT id, seqid, name FROM _TREE_
WHERE parent_id = i_parent ORDER BY seqid;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN qry;
REPEAT
FETCH qry INTO v_nid, v_ex_seqid, v_name;
IF NOT done THEN
IF v_ex_seqid != i_seqid THEN
UPDATE _TREE_ SET seqid = i_seqid, depth=i_depth WHERE id=v_nid;
END IF;
IF i_depth > 0 THEN
SET v_fullpath = CONCAT(i_fullpath, i_sep, v_name);
ELSE
SET v_fullpath = v_name;
END IF;
SET v_leaf =0;
SELECT COUNT(id) INTO v_leaf FROM _TREE_ where parent_id = v_nid;
UPDATE _TREE_ SET
fullpath = v_fullpath,
leaf = IF (v_leaf > 0, 0 , 1)
WHERE id=v_nid;
SET i_seqid = i_seqid +1;
#// do the children..
CALL _TREE__resequence_sub(v_nid, i_depth+1, v_fullpath, i_sep, i_seqid);
END IF;
UNTIL done END REPEAT;
CLOSE qry;
END $$
DELIMITER ;
Now our simple add node code just adds the node in the correct place, bumps the seqid along, so that you can then regenerate the tree.
DROP FUNCTION IF EXISTS _TREE__add_node;
DELIMITER $$
CREATE FUNCTION _TREE__add_node(
i_parent INT(11),
i_after INT(11),
i_name VARCHAR(128)
) RETURNS INT(11) DETERMINISTIC
BEGIN
DECLARE v_depth INT(11);
DECLARE v_seqid INT(11);
DECLARE v_ret INT(11);
DECLARE v_tmp INT(11);
SET v_depth = 0;
SET v_seqid = 0;
SET
Truncated by Planet PHP, read more at the original (another 3410 bytes)
To celebrate the release of the new edition of well-loved SitePoint book Build Your Own Database Driven Web Site Using PHP & MySQL, 4th Edition — by Kevin Yank, we’re publishing a chapter a day next week, beginning Tuesday the 7th of July.
Today, we’ve published the beginning of the series: the Introduction and directly from the book, Chapter 1: Installation. Over the weekend you can read chapter 1 and make sure your newly installed software is working properly, in readiness for next week’s chapters. At the end of the week you’ll have 4 complete chapters from the book and one bonus article, comprising another book excerpt.
Here’s what you’ll be receiving:
Chapter 2: Introducing MySQL
An introduction to databases in general, and the MySQL relational database management system in particular. If you’ve never worked with a relational database before, you’ll find this enlightening, whetting your appetite for what’s to come! In the process, you’ll build up a simple database to be used in later chapters.
Chapter 3: Introducing PHP
Here’s where the fun really starts. In this chapter, Kevin will introduce you to the PHP scripting language, which you can use to build dynamic web pages that present up-to-the-moment information to your visitors.
Chapter 4: Publishing MySQL Data on the Web
In this chapter you’ll bring together PHP and MySQL to create some of your first database driven web pages. You’ll explore the basic techniques of using PHP to retrieve information from a database and display it on the Web in real time. Kevin will also show you how to use PHP to create web-based forms for adding new entries to, and modifying existing information in, a MySQL database on the fly.
Bonus: How to Handle File Uploads with PHP
In this bonus excerpt from Chapter 12, you’ll learn how to accept file uploads from your web site visitors securely and store them.
Build Your Own Database Driven Web Site Using PHP & MySQL, 4th Edition is one of the most popular PHP books for beginners, and SitePoint’s first ever book. This shiny new 4th edition has been completely updated using only best-practice PHP. It’s essential reading for all budding PHP & MySQL developers. For more information, see the book page.
If you prefer to read the Adobe Acrobat PDF version of these first four chapters, you can download the first four chapters FREE.
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&did=adz&adtype=vertical" type="text/javascript">Found and reported a couple of PHP 5.3 bugs yesterday. That isn’t such a surprise; it’s a new release, after all, and we’re currently in the midst of developing code for the first time against 5.3 here at work. One of them is a crasher, but an obscure one reliant on the new-in-5.3 INI_SCANNER_RAW mode in parse_ini_file and a rather odd configuration file, so as these things go, it’s pretty minor, and scottmac has jumped on it very promptly indeed (thanks!). The response from Jani was interesting, though:
Thanks for not reporting this before release..
Now, Jani does a tremendous amount of work triaging PHP bugs and I — and every other PHP developer (particularly those of us who does this for a living) — owe him a huge debt for that. But frankly, I resent the implication that I’ve somehow sat on a crasher since before 5.3.0 was released and only submitted it now as some sort of weird vendetta against the PHP internals team. Funnily enough, I only found it while I was reducing the other, more trivial bug down to a minimal test case.
I get far worse things implied in my direction when I’m out on a Saturday night in Northbridge, so really, I’m not that fussed. (I’m obviously a bit fussed, though, since I’m writing this.) I do wonder how somebody new to the PHP community would feel, though — my guess is that you could forget about future bug reports in some cases, and that just isn’t a win for anyone.
Some use the classic tinyurl, then there's is.gd and bit.ly and a fair bunch of others.
As some people already wrote, and I feel no different here, broken links are baaad, mkay?
So the easiest way would be to get a short domain for yourself and run your own url shortener.
I am happy enough to have secured myself a not yet publicly announced 3-char .de domain which I'm planning to use for that. This and being bored for 2h led me to roll out my own shortening service.
Enter Shortcore - 259 lines of php code, working already.
It needs PHP 5.2.0+ (I think :P) and sqlite and I've put it up on github - it's BSD licenced and comments and patches are very much appreciated.
How to use it when it's installed:
- http://example.org/_[uniqueid] redirects to what you saved.
- http://example.org/_[uniqueid]_ shows a preview
- So I have "xxx.de/_ab" - as low as 10 chars for an url (excluding http://), that's not less than a bit.ly url (currently at 5+ chars after the /) and I can still put normal content (not starting with a "_") on the domain - fair deal I think
- there's a bookmarklet for easy saving, either provide the [uniqueid] or let it be generated automatically
- it's not meant as a public shortening service, so probably some basic auth has to be added
The PHP North West group has officially launched the website for this year's event - PHP North West 2009:
We're proud to announce the second edition of the PHP North West Conference, to be held on Saturday 10th October, 2009. Following from last year's successful debut, this event returns to bring a great mix of speakers and community from the north of England and beyond. With a local feel, there will be a packed day of talks from a range of speakers, socials Friday and Saturday night, and informal sessions running on Sunday for those making a weekend of it. We hope to see you there!
The site currently has links to their registration, Call for Papers and resources to use when linking to conference.
Released at Thu, 02 Jul 2009 17:02:30 GMT by ingorenner
Includes files: dummy-4.2.7.tar.gz (9361 bytes, 0 downloads to date), dummy-4.2.7.zip (20300 bytes, 0 downloads to date), typo3_src-4.2.7.tar.gz (8150210 bytes, 0 downloads to date), typo3_src+duk-4.2.7.zip (9684527 bytes, 0 downloads to date), typo3_src-4.2.7.zip (9626616 bytes, 0 downloads to date)
[Download] [Release Notes]
Released at Thu, 02 Jul 2009 17:01:51 GMT by ingmars
Includes files: typo3_src-4.1.11.zip (8746686 bytes, 0 downloads to date), typo3_src-4.1.11.tar.gz (7580835 bytes, 0 downloads to date), typo3_src+duk-4.1.11.zip (8795361 bytes, 0 downloads to date), dummy-4.1.11.zip (15228 bytes, 0 downloads to date), dummy-4.1.11.tar.gz (9558 bytes, 0 downloads to date)
[Download] [Release Notes]
New on WebReference.com is this look (part of a series) at working with XML in PHP, this time it's specifically covering the DOM functionality.
With this series of articles, I will try to simplify and demystify the use and application of XML and the DOM. First, we will look at what XML is and then move on to what functions are available for use to manipulate and use XML.
The tutorial introduces XML and gives a sample structure of a document and breaks it down to explain each of the parts. Following that they look at some of the XML-related functionality to create their sample XML file.
Vinu Thomas has a new post to his blog looking at using the MS-Excel Stream Handler class to push your data out to Excel (in more than just a CSV file).
If you're looking for an easy way to output your data from a PHP script into a Excel file, you've got to check out this script a> which I came across at the PHP Classes site. What this script essentially does is to implement a stream handler interface to write Microsoft Excel spreadsheet files.
Code snippets are included showing how to structure the data for the import and how to push that generated Excel file out to the user's waiting client.
2009-07-02(木)
One of the features included in the PHP 5.x releases is type hinting for validating that you have the right values for your functions and methods coming in. In this new post to his blog Ilia Alshanetshy takes a look at the the feature and gives a patch to add it .
On a general level most people agree it would be a good idea to have, since it is an optional feature and does not introduce any regressions, heck you can even mix type hinted code with the non-type hinted one. The "PROBLEM" has always been combining of PHP's typeless nature with type hinting, which is where the consensus has been difficult (impossible) to reach.
He mentions an example of why its such an issue (technically, both 1 and "1" are valid numbers) and includes a link to a patch that gives a new hint to help with the problem.
Unlike the other posts in this series, this one is quite specific to one type of service - REST - since it deals with status codes, specifically HTTP ones. The ideas are transferrable however and other types of service can return statuses in a similar way.
There's a few key things to think about when returning status codes. In earlier posts in this series these was discussion of using existing application framework to serve pages and changing the output mechanism accordingly. Usually a web page will return a status 200 for OK or also 302 for found, so this is fine when things are working normally. But when things aren't going quite so well, its useful to give alternative feedback that can be easily picked up by a client application.
When things go wrong there are a couple of different schools of thought of how the service should respond. One is that if, for example, the user supplies data which fails validation, the service could provide the OK response and a message to the user to let them know what needs validating - exactly as we'd return information messages to a user filling in a form. To be considered restful however, the service should more correctly return one of the "400" status codes, which means that the client made an error. Interesting and useful codes* in this series are:
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 406 Not Acceptable
- 408 Request Timeout
- 417 Expectation Failed
- 418 I'm a teapot
* I didn't say they were both useful and interesting
Using descriptive status codes allows the client to get the headline of the problem without having to parse a whole request to find out whether it is good or not. HTTP already has this feature built-in, and so we make use of it (HTTP is pretty cool really, makes a great protocol for services!).
Where an error occurs on the server side - it is usual to return a 500 error or another in the 500 series. This lets the client know there is a problem outside of their control; it is useful to include information about whether the client should retry and when. Having a defined protocol for retries helps avoid the situation where a system comes back up only to fall over again with all the traffic from people retrying every minute (or other interval) - this is a real concern for systems that are under heavy load.
Status codes are like a headline to the calling entity about what happened, and are a valuable tool in the web service toolkit. For bonus points, leave me a comment and tell me which is your favourite status code :)
On the Ibuildings blog today Ivo Jansch has posted a look at PHP 5.3 from a slightly different perspective - how development with it affects the management.
At our Techportal Cal Evans gave an overview of the important changes, to make migration easier for developers. In this post,I'm going to look at the migration from a less technical angle, and explain when migration to PHP 5.3 is a good idea and when not.
He talks about why you should consider the move up to PHP 5.3 and some of the things you should use to handle (and pay attention to) the migration.
Yesterday we had an entire day at Liip dedicated to various talks, workshops and hanging out together. It really reminded me again what an amazing company Liip is. Its really what I wished m company back in Berlin should have been. Fun, smart, successful, productive, agile, good. At any rate I wanted to mention the stuff we are working on in terms of OSS. Obviously Chregu and myself are active on PHP. Jordi is also an active member of the PHP.net community. But we have other less known stuff that should also get noted, like Jackalope, Mahara, Picok, GottaGo and Okapi.
Jackalope is an implementation of the client side JCR standard for PHP. This will enable us making happy agile frontends that are managed with all the various Enterprise features like versioning, ACL's etc. Liip created this project but is looking for others to join. We are already sharing the interfaces with the typo3 guys.
Mahara is a social networking platform that has spawned out of the Moodle e-learning community. Penny recently joined Liip and she was actually one of the original founders of the project.
Picok is a one of my babies. Its sort of an OSS iGoogle. So it allows you to easily create new so called portlets, that can aggregate content from various internal and external data sources and present them in a user customizable interface. Originally created for one of our clients the Raiffeisen Bank here in Switzerland. They were kind enough to let us open source the code. In return we won them a couple prizes at the Swiss Web Awards :)
GottaGo actually took the Swiss Web Awards by storm. It won the grand prize along with a few other category prizes. Its an iPhone app that basically finds the fasted route via public transportation from point A to B here in Switzerland. Oh and I should stop referring to it as GottaGo, since its now called "Transport".
Okapi is our super lightweight framework. Recently Chregu and I have started working on version 2. Basically we took various Symfony2 components and integrated them into our code. Currently its still in proof of concept stage, but it looks quite promising. I am really seeing a lot of potential in the service container and event dispatcher. I also think it could become a very useful addition to the Symfony eco-system as it seems quite feasible to migrate from Okapi2 to Symfony2 or vice versa. Meaning it will be able to choose if you want something simple and lean or you need something full features, without having to need to learn two totally different frameworks. Chregu has ported liip.to to this proof of concept, so check it out!
- Site News: Popular Posts for the Week of 07.04.2008
- Avent Labs Blog: PHP framework comparison benchmarks
- Paranoid Engineering Blog: CMS Battle: Drupal va Joomla va Custom Programming
- Doug Brown's Blog: Zend_Cache is Saving me Money!
- Zend Developer Zone: Desktop Image Uploaders Using Adobe AIR and JavaScript
- Mike Bernat's Blog: Installing Xdebug - Best Decision You Will Ever Make
- SaniSoft Blog: Code sniffs for CakePHP and then some more
- Sebastian Bergmann's Blog: Tutorial at ZendCon 2007
- PHPFreaks.com: PHP Security
- Lukas Smith's Blog: Making PHP 5.3 Happen
- Hiveminds Magazine: How to bridge PHP and Java on Windows with Apache Tomcat
- Stefan Priebsch's Blog: Custom Coding Standards with PHP_CodeSniffer
- Community News: Identi.ca - a PHP-based Twitter clone
- IBM developerWorks: Getting Graphic with PHP
- Jaisen Methai's Blog: Stop including class files and use __autoload() instead

With over 40,000 copies sold of the three previous editions, I’m very pleased to announce the latest title hot off the SitePoint production line:
Build Your Own Database Driven Web Site Using PHP & MySQL (4th Edition) — by Kevin Yank
One of the most popular PHP books for beginners, this shiny new 4th edition has been completely updated using only best-practice PHP.
In this book you’ll learn how to:
- install PHP 5 and MySQL 5 on Windows, Linux, or Mac OS X
- gain a thorough understanding of PHP syntax
- master database design principles and SQL
- build a working content management system
- add, edit, and delete web content without using html
- create an ecommerce shopping cart
- utilize sessions and cookies to track site visitors
- craft SEO-friendly and memorable URLs
And a whole lot more …
At around 480 pages, this book is an easy read. As you move through the book you’ll quickly notice that it’s written in a clear tutorial format that’s easy to understand, and illustrated with plenty of screenshots and diagrams, providing quick visual cues. If you hate wading through dry, academic-style “how to” texts, this book will be a breath of fresh air to you.
If you’ve never built a database driven web site and you’re looking to go beyond the limitations of a static site, this book will start you off in no time.
And if you have built database driven web sites before, the extensive PHP/MySQL reference guides included will ensure this book remains an extremely handy desk reference.
Check out the free sample chapters or order a copy today.
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&did=adz&adtype=vertical" type="text/javascript">Dave Neary summed this up well:
...I fundamentally disagree with discouraging someone from pursuing a technology choice because of the threat of patents. In this particular case, the law is an ass. The patent system in the United States is out of control and dysfunctional, and it is bringing the rest of the world down with it. The time has come to take a stand and say “We don’t care about patents. We’re just not going to think about them. Sue us if you want.”
With Midgard we have prior art on some software patents. Software patents only promote big multinational monopolies, and therefore are against the interests of both Europe and the Free Software movement. They're silly, don't apply here, and therefore the only rational response is to ignore them.
Technorati Tags: softwarepatents

digg に投稿する
del.icio.us に追加する
はてなに追加する