Running Your PHP Applications on IIS

213 days ago
tags:

Today Microsoft announced the official release of their FastCGI extension for IIS 5.1/6.0, which greatly improves the performance and reliability of PHP on Windows’ flagship web server.

Learn more



Programming with Configuration Files

303 days ago
tags: , , ,

Recently I was working on developing an application that required a configuration file to setup. I considered several options for the file, keep it in the native language (PHP), make it plain-text or use XML. I didn’t like any of the options because the configuration has to be approved by certain stakeholders of the data at various stages throughout the life of the application.

XML is too hard to read for management-types. Plain text wasn’t all that easy to handle from a code perspective. I could have used a native language configuration file that read more like plain text (mostly comments, few directives, etc), but still was not liking it.

Then I remembered that when I played with Ruby on Rails it used something called YAML, and thought I’d give that go. It didn’t take too long at all to get the hang of writing the syntax for YAML. I then needed to find a way to process it with PHP. I found a few.

I started with the top entry on a Google search for PHP YAML. I found spyc, which is a very simple YAML class for PHP. I also found Syck, which is apparently more widely used and ported to several languages (although Ruby looks to be the primary focus). But I decided to download spyc, which appeared to geared toward PHP, gave it a whirl and instantly had what I needed. I liked it so much, I packaged it up for Fedora. I should probably also mention that I looked at JSON, but found YAML to be more complete and easier to read for what I needed to do. JSON is cool though in that it is a subset of YAML for the most part and works nicely with Python.



Zend Framework 1.0 Production Released!

313 days ago
tags:

Today Zend announced the official release of the Zend Framework 1.0!! I’ve been using the ZFW for some time now, and already have it running in a production environment (to power http://www.beginningphpandmysql.com/). Can’t say enough good things about it, if you’re looking for a killer MVC framework with plenty of opportunities for extensibility, check it out.

Read the announcement



Symfony Forge Launched!!!

386 days ago
tags: ,

Along with the Zend Framework and CakePHP, the symfony web framework is considered to be one of the PHP “big three” frameworks. Having personally used it for a few projects, I can vouch for its power, flexibility, and ease of use, and in fact am so enthusiastic about it that we published the definitive book on the topic (written by symfony’s creator and lead developer) just a few months ago.

This week the project took another major step forward with the launch of symfony Forge!. Intended to be a central location for community plug-ins, discussion, and other tools, if you’re using symfony I strongly encourage checking it out.

Check out the symfony Forge



Delphi for PHP

439 days ago
tags:

Apress author Chris Judd wrote to let us know Borland is going to soon release Delphi for PHP, which it’s touting as the “first competely integrated visual Rapid Application Development environment for PHP”.

This is certainly an interesting development, as visual PHP development tools have long been sorely missing. While I’m very happy with PDT, clearly there’s a significant market for these sorts of tools. I’ll contact Borland about obtaining a review copy, look for an update here in the coming weeks.

Learn more about Delphi for PHP

Jason



symfony 1.0 Released!

445 days ago
tags: ,

Francois Zaninotto wrote this morning to inform me that symfony 1.0 has been released! I’ve been using the symfony framework for several months now, and personally think it to be the best of the bunch. If you’re looking for a great PHP framework, this is it.

The timing of this release was impeccable, as Francois and fellow symfony lead contributor Fabien Potencier co-authored “The Definitive Guide to symfony”, which Apress published just last month. The book is 1.0-compliant so check it out if you’re looking for a great learning resource.

Read more about the release

Jason



Zend Framework Cache Improvement

457 days ago

About three weeks ago, I posted my initial thoughts on the Zend Framework. One of my complaints was the Zend_Cache did not accept lifetimes on a per object basis, but rather the lifetime was at an application level. I just received notice in my inbox that the issue has been fixed! The change is currently in svn, and should be in the 0.80 preview release. Thanks go to Fabien for the fix.



Possible addition to array syntax in PHP

461 days ago
tags:

Andi Gutmans approached the php-internals mailing list with a proposal to add a new syntax for array declaration. The current split among the big players in PHP development looks to be about 50/50. The general thought of the opposition is that it is an unnecessary change that will only lead to confusion in the future. Why create two ways of doing the same thing? I personally agree with the opposition. I don’t see anything more elegant about the new proposed syntax. Adding such a new syntax will only makes scripts less readable (because you would have to pay attention for two different methods). Those for the change cite that other languages have this syntax and they personally believe it is more clear. Are those two reasons really enough to justify such an addition?



FastCGI Technical Preview 2 Released!

464 days ago
tags: , ,

A few months ago I reported on Microsoft’s attempts to improve PHP’s performance on the Windows platform. A short time later, Zend and Microsoft announced a partnership intended to make this effort official.

The result of this collaboration is coming to fruition, as this week they released the second technical preview release of FastCGI.

Progress in this area is a pretty big deal, because countless PHP developers have historically built their web applications on Windows, only to move them over to Linux due to these longstanding performance and stability issues. Soon these developers will be able to continue using a standardized environment if they so choose.

Learn more about the FastCGI release

Learn how to install FastCGI/PHP

Read Zend’s press release regarding the collaboration

Jason



PHP IDE now PDT

467 days ago
tags: , ,

The project formally known as PHP IDE is now known as PDT, or PHP Development Tool. Essentially this is a PHP development environment for Eclipse. If you haven’t checked it out, I urge you to do so. This is the best PHP development environment I have used (and still use), free or commercial.



Introducting Primitus

467 days ago

I came across this interesting proposal for an application generator built on top of the Zend Framework. It is called Primitus and is the brainchild of John Coggeshall. It looks very interesting and could quiet down those that complain about Zend Framework not living up to the ease of use they imagined it would. I’ve heard all too many people think that ZF should be as easy to use as Rails. In many ways I agree and this could provide that hand holding many want. Of course, those that still want more flexibility can use ZF without this (or another) application generator. You’ll find a first release of Primitus at the end of the propoal.



Preview The Definitive Guide to Symfony

473 days ago
tags: ,

The authors of the upcoming book, The Definitive Guide to Symfony, have posted a sample chapter for you to get a sneak preview. The sample chapter covers Unit and Functional Testing and should be a treat for anyone interested in Symfony. (hint: you can find a different sample chapter at the first link in this post)



Viewing Large Record Sets in PHPMyAdmin

484 days ago
tags:

I’m currently working on an e-commerce project involving a relatively small number of database tables. However the clients table consists of 19 fields, making for difficult data review and debugging within PHPMyAdmin, even at 1280×768 resolution.

The answer is simple, at least if you’re using Firefox. Firefox offers three hotkeys for changing the text size, and resultingly, the amount of text you can see on one screen:

Ctrl+: Increase text size
Ctrl-
: Decrease text size
Ctrl0: Return to default text size

When you’re dealing with a large table, just hit Ctrl- a few times. Once you’ve reviewed the data (or you’re eyes start to hurt), hit Ctrl0 to return to the default text size.



Initial Thoughts on the Zend Framework

487 days ago

I’ve been using the Zend Framework to recode a large website and I’ve generally been very pleased with the results and ease of use. I’ve found that using the framework has significantly decreased my development time and really just given me cleaner, easier to maintain code. Of course, these are the goals of any framework. I do have a couple of issues I’ve come across and it is those I’d like to talk about.


Click here to read more


Very Nice Zend Framework Tutorial

497 days ago

I’ve been on the hunt for any and all documentation I can find on the Zend Framework. I came across a tutorial that’s been around for awhile, but constantly updated. I figured that if I hadn’t seen it before, maybe you haven’t either. It’s the best tutorial I’ve found to date for someone looking to learn how to utilize the MVC capabilities of the Zend Framework. You can find the tutorial at Rob Allen’s blog.



Ilia Introduces mail() logging for PHP

513 days ago
tags: ,

Ilia Alshanetsky has released a patch for PHP that will allow system administrators to log the source of mails sent through the mail() function and also add a X-PHP-Originating-Script header to each mail. This is a great step in the right direction as a variety of PHP applications (note I said applications, not PHP itself) have been plagued with security holes that lead to spam being sent out by the server.

I say this is a step in the right direction, because it does not address a PHP script being able to communicate directly with the SMTP server and not utilizing the mail function. It’s great that this is being done though, and hopefully it will make it into the PHP standard builds sometime soon.



PHP 5 Adoption Trends

514 days ago
tags:

I’ve come across a few rather interesting links regarding PHP 5 adoption that I thought worth passing along. With PHP 6 due out next year, it’s odd, and perhaps a bit disconcerting that PHP 5 adoption is so slow. Personally, I couldn’t imagine using version 4, what with all the great features PHP 5 brings to the table.

In a recent blog post, Ilia Alshanetsky cites some adoption numbers, asks his blog readers why they haven’t upgraded yet.

Nexen.net adoption statistics

Notably, back on July 16, core PHP developer and Zend co-founder Andi Gutman posted a blog entry titled “PHP Adoption Has Tipped!”. He cites Zend’s technical support statistics as evidence PHP 5 adoption is tipping, noting over 50% of clients are using PHP 5. In fairness, he also cites other numbers which fly-in-the-face of this conclusion.

Jason



PHP Performance Roundup

515 days ago
tags: ,

Here are some interesting links regarding PHP performance tips. I hope you find them all as informative as I have.

  • 5 PHP Performance Tips You Probably Don’t Want To Hear: Marco has some good tips that aren’t like many of the other performance tips you’ll find.
  • A HOWTO on Optimizing PHP: John Lim with a very detailed article on optimizing PHP.
  • Accelerating PHP Applications: Slides from a talk by Ilia Alshanetsky. Updated slides in PDF form found here.
  • Cluesheet – Tips for PHP Developers: Interesting “clue sheet” that has a section on performance.
  • How to install Alternative PHP Cache: Justin Silverton tells us how to install APC, a opcode cache for PHP.


  • symfony 1.0 Beta Released!

    527 days ago
    tags:

    Over the last several months I’ve experimented with each of the “big three” PHP frameworks, namely CakePHP, symfony, and the Zend Framework. All three offer unique features and advantages, and are worth a serious look if you’re interested in using a “Rails-like” framework for the PHP language. However, of the three I’ve settled on symfony for current projects, and am experiencing great success using it to create a new e-commerce website I’m soon to deploy.

    At any rate, yesterday version 1.0 beta was released! There’s quite a few impressive features and performance gains to be had with the new beta. I highly recommend taking a look at all symfony has to offer if you want to greatly streamline your website development time.

    Learn more



    Namespaces in PHP 6

    543 days ago
    tags:

    There’s a fairly interesting thread on the php-dev list regarding the inclusion of namespaces in PHP 6, you can find it here.

    I find both sides of the argument quite compelling, and while FWIW I’m in favor of including them in the next release, I’m somewhat indifferent to the matter. According to one of the very latest messages in the thread, Zeev Suraski confirms they simplistic support will likely be enabled, stating:

    “I think there are fair chances we’ll introduce a very simplistic namespaces capability in PHP 6. It’s pretty clear it will not have the notion of imports, and will be very much focused on classes (as opposed to functions and variables). In fact, I think you can very much imagine them as being a new way of writing a class name – just imagine you could specify a single colon (or whatever) in your class name.

    Anything beyond that is going to result in a significant slowdown of the execution engine and open a can of warms regarding scoping and symbol resolution. Just to clarify what Rasmus said (which is indeed what was agreed for PHP 6) – we will add namespaces to PHP 6 if we can find a good way of defining their semantics in the PHP spirit as well as an acceptable way to implement it. Those two reasons very much limit what we can or cannot do with namespaces in PHP, especially the first one. ”.

    Will be interesting to see how this pans out!

    Jason



    Installing PHP 6 Gotcha

    544 days ago
    tags:

    PHP 6 has been in the works for some time now, and promises a number of long-awaited new features, including most notably complete Unicode support and namespaces. If you’re interested in giving the latest build a try, head on over to http://snaps.php.net, and download the latest source or Win32 package.

    Presuming you’ll want to install it as an Apache 2 module, there’s a minor inconsistency that I’d imagine is tripping a few people up (present party included). When adding the LoadModule directive to Apache’s httpd.conf file, you need to continue referencing php5_module, even though you tie it to the php6 DLL. For instance, here’s what the relevant lines of my Windows httpd.conf file looks like:

    LoadModule php5_module “c:/php60/php6apache2.dll” #LoadModule php5_module “c:/php520/php5apache2.dll” #LoadModule php5_module “c:/php514/php5apache2.dll” #LoadModule php5_module “c:/php5/php5apache2.dll”
    AddType application/x-httpd-php .php
    PHPIniDir “c:/php60”

    Also, note I’ve used the PHPIniDir directive to point to the location of the PHP 6-specific php.ini file. This is because the php.ini file has changed for PHP 6 due to the removal of several features.

    Jason



    Forms Validation with CakePHP

    551 days ago
    tags: ,

    Neglecting to validate user input is akin to foregoing any defensive gameplan for containing the NFL’s leading rusher. Chances are sooner or later you’re going to get run over. Yet even in spite of the dire ramifications of doing otherwise, many developers choose to ignore the potential problems presented by user input, reasoning that data validation is tedious and distracts them from the larger goal of building a working application. The result? Corrupt and incorrect data, cross-site scripting and SQL injection attacks, and a giant headache come Monday morning.

    There really is no way around it anymore: you must validate user input within every web application. However, because data validation is a task faced by all developers, and it follows a fairly rigorous specification regardless of where its ultimately applied, the task seems suitable for automation by a framework. CakePHP does exactly this, going a long way towards making data validation a snap.

    In the second installment of this occasional Developer.com series on this powerful framework, I’d like to show you another way frameworks can make your life easier by demonstrating CakePHP’s data validation capabilities.

    Read the article



    Microsoft inks multi-year deal with Zend

    557 days ago
    tags: ,

    Upon my return from the Microsoft Web Developers’ Summit a few weeks ago, I penned an article for TechTarget discussing Microsoft’s efforts to ensure PHP runs smoothly on IIS. Today, Reuters is reporting this collaborative effort has been made official, with both sides agreeing to work together towards this goal.



    Design Patterns and PHP

    613 days ago
    tags:

    While developers should be able to think outside of the box, it’s clear that much of our job revolves around repeatedly implementing similar solutions, albeit within different problem-spaces.

    The development community refers to these repeatable situations as patterns, and they help you write code faster and more efficiently. Because pattern implementation is heavily dependent upon a language’s object-oriented capabilities, PHP users have only really been able to take advantage of them since the version 5 release. In light of this, I thought I’d take a moment to compile a list of reading resources for those of you new to the topic, first listing a few language-agnostic definitions, and then moving on to a few tutorials and a book devoted to implementing patterns in PHP.


    Click here to read more


    Automate Amazon Research with the Zend Framework

    661 days ago
    tags: ,

    Like most Web developers, I’ve become enamored with the myriad Web frameworks popping up everywhere. Symfony is very cool, as is Cake. But the Zend Framework offers a particularly compelling component that I couldn’t resist using for a recent personal project involving aggregating Amazon sales rank information for Apress’ open source line (of course we’ve long aggregated such statistics, but I wanted to recreate my own solution for kicks).

    My latest SearchOpenSource tutorial describes this project, showing you how to take advantage of the Zend Framework to create your own aggregator. While it’s not an introduction to the framework, you should nonetheless be able to follow along fairly well provided you’ve some understanding of how MVC works.

    » Read the article



    PHP 5 Adoption has (not) Tipped!

    663 days ago
    tags: , ,

    This morning I came across Andi Gutmans’ blog posting titled PHP 5 Adoption has Tipped! I found his post especially interesting as I just posted a week and a half ago about the continuance of PHP4 as the primarily installed version of PHP (PHP4, The Energizer Bunny?). At first I wondered if there were some new statistics released that I hadn’t seen, but that wasn’t the case.


    Click here to read more


    Serving Cached Data For Improved Performance

    667 days ago

    Over the past day I've been going through a few web applications and preparing them in the event they get digged or slashdotted. One of my primary goals was to cache as much data to disk, rather than hitting the database for it each time. Now, most of the web applications I have written myself, so I didn't have the luxury of some type of premade mod or plugin. In one case, this textpattern installation, I did have that luxury.


    Click here to read more


    The Power of PHPEclipse

    668 days ago
    tags: ,

    All too often I come across beginning PHP tutorials in which the author praises the ease in which newbies can get acquainted with the language, and invites them to fire up their favorite text editor to begin coding. Because so many newcomers begin coding PHP on Windows, often this text editor is Notepad. Last time I checked, Notepad offered nothing by way of coding convenience, nor a means for extending the application to allow for such amenities.

    Why not point newcomers to a tool that will help these individuals get further acquainted with PHP without getting lost in unnecessary organizational details such as tabbing between multiple windows (most notably editor and browser), having to hunt down missing quotation marks, and in the case of having a significant bug, being left to simple echo statements?


    Click here to read more


    Displaying Times and Dates in Other Languages with PHP

    670 days ago

    So far, all the date and time output has been in English. From the point of view of someone for whom English is the primary language, this is not necessarily a bad thing. However, quite a lot of people in the world use other languages and prefer to use websites in those languages. You do not want to display something like “Guten Morgen! Heute is Monday, der 15th March� to users of a German-language news portal any more than English-speaking users would want to see something like “Good Morning! It’s Montag, the 15. of März� on an English-language site.


    Click here to read more


    PHP4, The Energizer Bunny?

    673 days ago
    tags: ,

    How long can PHP4 keep going? Well, the way things currently stand, the answer could be “forever”. According to recent statistics, PHP4 still holds a whopping 90% of the market share. It is no wonder that the vast majority of PHP applications have either not added PHP5 support or have continued to maintain themselves as primarily PHP4 applications.


    Click here to read more


    Using the Google API from PEAR

    680 days ago
    tags: , , , ,
    The Services_Google package is simply a wrapper around the SOAP extension and is used to access the Google Web APIs (http://www.google.com/apis/reference.html) for the search engine, spelling suggestions, and cache. To access any of these services, you must obtain a license key by registering for an account. A link to the registration page is available from the previously mentioned URL. Because this package is a wrapper for SOAP, both PHP 5 and the SOAP extension are prerequisites for installing and using this package.
    Click here to read more


    A Quick Tutorial of PEAR DB

    681 days ago
    tags: , , ,

    So you’ve written a great application with PHP and it is up and running smooth. Then, your boss calls and tells you that your company won’t be using MySQL anymore. You’re moving to Oracle. Your application is dead in the water. You should have used database abstraction.


    Click here to read more


    Xdebug: A PHP Debugger and Profiler

    687 days ago
    tags: , , ,

    If you’ve been looking for a way to help debug and profile your PHP code, you will want to check out Xdebug. While this isn’t something new, it is an area that many people are unfamiliar with and are unaware that such a tool exists. This is a tool that any serious PHP developer needs in their tool belt. If you are at all concerned about performance of your PHP scripts, the profiler alone in Xdebug is worth checking out.


    Click here to read more


    Introducing Google’s Geocoding Service

    687 days ago
    tags: ,

    My ongoing Developer.com series covering the Google Maps API (tutorial 1, tutorial 2, tutorial 3, tutorial 4) shows you how to use this great service to build interesting and useful spatial Web applications. Yet one of the glaring omissions from the API has been the ability to map locations without the use of third-party solutions for converting mailing addresses to their corresponding coordinates; just as is the case with the Yahoo! and Microsoft Virtual Earth mapping APIs, locations can only be pinpointed using their latitudinal and longitudinal descriptors. Whereas the latter two solutions have offered built-in conversion capabilities for some time, Google Maps API users have had to rely on services such as geocoder.us or the US Census Bureau TIGER/Line data for such tasks.


    This longstanding feature request was satisfied on June 11 when Google quietly added geocoding capabilities to the API. What’s more, this feature isn’t limited to the U.S.; street-level geocoding is also offered for Canada, France, Germany, Italy, Japan, and Spain! While limited to 50,000 daily requests, it’s fair to say such constraints won’t affect most users, particularly if caching is implemented. This tutorial shows you how to use this new feature, further streamlining your use of this wonderful API.



    Quick and Easy Ajax with PHP

    689 days ago
    tags: , ,
    So, I’ve been searching for a simple method to quickly create some Ajax based applications using a PHP backend. My requirements were simple and consisted of only one item: avoid hand coding JavaScript as much as possible. After much searching and reading of APIs and documentation, I came across a great library called xajax.

    Click here to read more


    The #1 Security Flaw in PHP Applications

    696 days ago
    tags: , ,
    The Open Web Application Security Project released a document describing the top 10 security issues in web applications. David Sklar gave some practical examples of these vulnerabilities in PHP applications. There is one item I find missing from the list however and it is what I consider the top security flaw in PHP applications.

    Click here to read more


    Clean that input!

    699 days ago
    tags: , , ,

    If you are programming any publicly available web site, you need to be aware that user input can be tainted by a malicious user. You need to clean the input to be sure there are not any XSS attacks, SQL injection attacks, or just any HTML inserted you don’t want.


    Click here to read more