Ian Christian has an informative new post for the Symfony developers out there. He’s figured out a way to handle uploaded files with Symfony’s admin generator relatively easily, changing the filename option.

When a file is uploaded using sfForm in the admin generator, by default the filename that’s used is a random string, which can look bad in URLs. If you want to change this, it’s not immediately obvious how - but it is incredibly simple.

The Symfony project does have some documentation on the topic, but it’s not the easiest to read. It basically boils down to is defining a function in your extended class based on the name of the file where you can change the name however you’d like. Code snippets are included to make the point a bit more clear.

Jani Hartikainen poses an interesting question on his blog today - is it more correct for a function, having failed at its job, to return a value of throw an exception.

You have created a nice, well written function, but you realize you forgot something: The failure case. What should a function do when it fails? There are two schools for this - the “throw an exception” school and the “return an error value” school. But which of these is the correct approach?

He suggests that this debate has stuck around from the time when there weren’t exceptions in several popular programming languages and that returning the value was the only valid way. He touches on what an exception condition is (with a few code examples) and situations where each choice might be the right way to go.

Brian Swan has posted the second part of his series looking at the difference between the MSSQL driver and the SQLSRV drivers for connecting to SQL Server databases from PHP (part one can be found here). He gets a bit more detailed in this second post.

I’m aiming to provide a high-level comparison that you might use if you were considering moving to the SQLSRV extension, but I think there is also some interesting information if you are just curious about the differences. […] In cases where a short note wasn’t enough (and there were several of these), I’ve provided relevant links to topics in the SQLSRV documentation.

He talks about things that one offers that the other doesn’t, like prepared statements (sqlsrv) and working with stored procedures (mssql). He also mentions error handlng, persistent connections and scrollable cursors in sqlsrv. Finally he gets into a one-to-one function comparison of the two drivers with the sqlsrv function list coming up a bit short compared to the features of the more recend (and well-supported) mssql driver.

Phil Sturgeon has posted a look ahead at everything you need to know about the next version of the popular CodeIgniter framework, version 2.0.

It has been 6 months since the last CodeIgniter minor update and 18 months since the last major update. Through all this time we were given no information about the next release of CodeIgniter, but finally 2.0 is on the way.

Because of the Ellis Labs move to Mercurial for its version control system (and BitBucket for the repository), it allows for a more “social coding” environment where it’s easier for developers to just fork and contribute. Other major changes for this upcoming version include the fact that PHP4 support will officially be deprecated, driver libraries, application “packages”, a smaller reserved controller name list and the dismissal of plugins.

Check out the Changelog for more detailed information as things are updated.

Popular posts from PHPDeveloper.org for the past week:

In an opinion piece posted to the php|architect site Marco Tabini suggests that we (as developers) are doing it wrong as we move further and further away from the pragmatic side of programming into the abstract.

No matter how advanced the techniques that we use, there is always something that we could be doing better. […] Which one is right? The real problem is that the answer to that question is, “yes.” That’s because it lacks a specific context in which it can be inserted.

He suggests that, in our quest to figure out what the perfect case for any situation, we stop focusing on the practicality of writing applications to accomplish goals. Sometimes it’s not about getting the right theory behind the code - sometimes it’s just doing it.

Brian Moon has a quick post that links to a but of code that gives you a progress bar for the command line that’s flexible enough to be used in an number of situations.

Was just looking through some code and came across this function I wrote some time ago. If you do a lot of your processing scripts in PHP like we do, you probably need to know what is going on sometimes. So, I made a progress bar for use on the cli. I thought I would share it.

You can see a demo of it here (screencast) or just download the code. Comments on the post also point out the PEAR Console_Progressbar package and the ez Components class for creating a more advanced progress bar.

Alan Skorkin has a recent post to his blog about a trouble that many WordPress users have come across in working with their content and the WP-Syntax plugin (for displaying code) - a special character escaping bug that escapes characters that don’t need it.

Suffice to say, [WP-Syntax] does the job fine except for one very annoying issue. Whenever you have any kind of special characters in your code (which you inevitably do e.g. , & etc.), these always render as their escaped representations.

It only happens with the WYSIWYG editor for writing content (which the tool’s FAQ recommends turning off) but there’s a better solution that Alan found - change a line of code in the plugin to use the htmlspecialchars_decode function to rid your install of this pesky escaping bug.

In a new post to his blog today Eli White takes a look at an interesting use of lambda functions he’s figured out for a his development at work.

I found a very specific use out of the blue of Lambda functions that I have now used and I see as a great use-case. Which is specifically passing functions/logic from your Controller to your View. In the case of Goodsie, I’m using PHP for my templating language and as usual I’m trying to remove as much logic from my View as possible, while still allowing the view to be malleable.

His method centered around a pagination subview that he wanted to make flexible enough to work with both the standard page view and with an ajax request. Lambda functions came to the rescue by dynamically creating a function based on the request need.

What do you get when you cross a hundered or so geeks, mountains of pizza, truckloads of energy drinks, and a mission to help the charities of the world beef up their online offerings? GiveCamp.

Next Page »