News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Throw an exception when simplexml_load_string fails
September 09, 2014 @ 09:27:13

In a quick post to his site Rob Allen shares a class that he's created to handle and throw an exception any time that the load from a SimpleXML parsing fails.

I keep having to look up how to stop the warning that are emitted when simplexml_load_string & simplexml_load_file fail, so this time I've written the world's simplest little class to take care of it for me from now on.

His "Xml" class wraps around the SimpleXML functionality and checks to see if the resulting object is false. If it is, it uses some internal error handling to fetch the error message result and throws it as a "RuntimeException". This error string comes from a "getXMLErrorString" function that uses the libxml_get_errors function to get the resulting error list.

0 comments voice your opinion now!
simplexml load string file fail exception error handling

Link: http://akrabat.com/php/throw-an-exception-when-simplexml_load_string-fails/

Three Devs & A Maybe Podcast:
Understanding Character Sets and Encodings
May 14, 2014 @ 13:12:06

The Three Devs & A Maybe podcast (with hosts Michael Budd, Fraser Hart, Lewis Cains and Edd Mann) has posted their latest episode (#24) talking about character sets and encodings.

Having only just recently been bit by the character encoding issue again, we thought it would be a good time to bring it up on the podcast. Starting from the beginning with ASCII, we move on to discuss how 8-bit compatible machines brought way to the ISO-8859-* standards. This leads us on to Unicode, with the goal to develop a single character-set encoding standard that could support all of the world's scripts. Finally, we discuss the de-factor character encoding implementation used on the web today 'UTF-8', and reasons why this is the case.

Lots of different topics are mentioned including reversing a Unicode String in PHP using UTF-16BE/LE, portable UTF-8 and a YouTube video covering Pragmatic Unicode. You can listen to this new episode though the in-page player, by downloading the mp3 or subscribing to their feed.

0 comments voice your opinion now!
threedevsandamaybe podcast ep24 unicode character set encoding utf8

Link: http://threedevsandamaybe.com/posts/understanding-character-sets-and-encodings/

Three Devs & A Maybe Podcast:
Exception and Error Handling
May 01, 2014 @ 11:28:48

In the latest episode of the Three Devs and a Maybe podcast Michael Budd, Fraser Hart, Lewis Cains and Edd Mann look at error and exception handling in PHP applications.

In this weeks show we introduce error handling, focusing on how exceptions are used. Initially touching on a brief history of exception's origins, we move on to highlight how languages such as PHP and JavaScript implement them. We round up the chat with a 'pros and cons' breakdown and a fun-packed quiz.

You can listen to this latest episode either through the in-page player or by downloading the mp3 directly. You can also subscribe if you like what you hear and want more great episodes.

0 comments voice your opinion now!
threedevsandamaybe podcast ep22 exception error handling

Link: http://threedevsandamaybe.com/posts/exception-and-error-handling/

Evert Pot:
PHP 5.5.10 timezone handling changes
March 31, 2014 @ 12:29:27

Evert Pot has a new post sharing some of the changes in DateTime handling that he's updated in the latest release in the PHP 5.5.x series.

PHP 5.5.10 got released a few weeks ago, and among other things, it added some new functionality related to timezone handling. In short, [subtracting from UTC] now works. Normally this would not be recommended, as you really should specify timezones based on their geographical location. This information is not always available though, so it's a welcome new feature.

Other changes include the removal of the automatic translation from "UTC" to "GMT" as well as errors being thrown when one of the "odd" timezones are used (he provides the list). Additionally, an update around timezone "guessing" has been added and the fallback that was in place has been removed.

0 comments voice your opinion now!
timezone change datetime utc gmt error names

Link: http://evertpot.com/php-5-5-10-timezone-changes/

Matthew Turland:
Travis and Composer and virtPHP, oh my!
March 27, 2014 @ 10:28:55

Matthew Turland has a new post today to his site looking at the combination of three different technologies - TravisCI, Composer and VirtPHP - and an odd error he was getting from his build about a missing requirement "php".

In the first build, everything worked fine under 5.4 and 5.5, but upon getting to the composer install instruction to install project dependencies and PHPUnit, the job for 5.3 failed with some rather unintuitive output from Composer that implied it didn't recognize the platform package requirement that I'd provided for the minimum PHP version. [...] Since the cause of my issue wasn't immediately obvious from Composer's output, my first thought was that I needed to begin my attempt at troubleshooting the issue by replicating it on my local machine.

This is where VirtPHP came in. This tool provides an environment where you can install and configure multiple PHP configurations and switch between them easily. It provides a "glue" between the phpenv and php-build projects to make management of the results simpler. He talks about how he configured and set up his environments...and figured out his Composer problem.

0 comments voice your opinion now!
travisci composer error virtphp environment

Link: http://matthewturland.com/2014/03/26/travis-and-composer-and-virtphp-oh-my

Derick Rethans:
Understanding Valgrind errors (1)
February 04, 2014 @ 11:03:02

Using the Valgrind tool can give you a good window into the inner workings of your PHP script (at a very low level) but the results it gives can be a bit confusing to interpret. In his latest post Derick Rethans uses the memcheck tool that comes as a part of Valgrind to monitor memory usage and interprets some of the results.

Memcheck is really valuable for C and C++ developers and something you should learn, especially when you write PHP extensions. Memcheck's error messages can sometimes be difficult to understand, so with this (infrequent series), I hope to shed some light on it. Let's have a look at the following Valgrind error output, which I encountered while debugging issue PHP-963 of the MongoDB driver for PHP.

He walks though the output and how to spot the actual error - a reference to a null pointer in the C code. He tracks it back through the code and finds the spot where it references the wrong memory segment in the Mongo PHP extension code.

In short, an error where Address 0x38 is not stack'd, malloc'd or (recently) free'd has a low address in the message often means a NULL-pointer dereference.
0 comments voice your opinion now!
valgrind error memcheck mongo extension

Link: http://derickrethans.nl/valgrind-null.html

Kevin van Zonneveld:
It's Almost 2014 and We Are Still Committing Broken Code
December 30, 2013 @ 09:19:28

Kevin van Zonneveld has a new post that, while not PHP specific, does have a handy script that will help you stop committing broken code.

Whatever the reason, it's almost 2014 and we are still committing broken code. This needs to stop because best case: Travis or Jenkins prevent those errors from hitting production and it's frustrating to go back and revert/redo that stuff. A waste of your time and state of mind, you were already working on other things. Worst case: your error goes unnoticed and hits production.

To help resolve the problem, he suggests using the "hook" system common to most version control software. In his specific example, he shows the use of a pre-commit hook that fires off a bash script on the files being committed. He includes the full code for this bash script that includes a check for PHP scripts using the built in PHP linter (the "-l" option on the command line). He also includes the commands and updates you'll need to make to get it installed on git.

0 comments voice your opinion now!
git precommit hook syntax error bash script tutorial

Link: http://kvz.io/blog/2013/12/29/one-git-commit-hook-to-rule-them-all/

Mathias Verraes:
Value Objects and User Interfaces
November 18, 2013 @ 11:35:07

Mathias Verraes has a new post today with a response to an email he received about some comments on a recent Elephant in the Room podcast about Value Object usage. The question asks about usage of Value Objects, specifically when it comes to things like country information.

There's nothing intrinsically wrong with modeling countries as entities and storing them in the database. But in most cases, that overcomplicating things. Countries don't change often. When a country's name changes, it is in fact, for all practical purposes, a new country. If a country one day does not exist anymore, you can't simply change all addresses, because possibly the country was split into two countries. Whenever you have this kind of friction, there's usually some missing concept screaming to be discovered.

He talks some about the concepts around the "country" data and some of the functional concerns around it (duplicate checking, validation of existence, etc). He takes the concept and breaks it out into two different concepts - the actual Value Object of a single country and an "AvailableCountries" set (and "AvailableCountryRepository").

0 comments voice your opinion now!
value object country example registry set

Link: http://verraes.net/2013/11/value-objects-and-user-interfaces/

PHP Manual Masterpieces:
I Can't Spell PBKDF
November 13, 2013 @ 09:58:08

On the PHP Manual Masterpieces site has a recent post looking at PBKDF and PHP (and, more specifically, the information that's presented about it in the manual).

So why are we here? Well, a faithful follower slipped me a tip to check out the documentation. It turned out I agreed: I don't like it. [...] Let's be clear: I have read the backing C code of this feature and I see nothing wrong with the actual functionality. My issues are strictly with the documentation and the API, both of which are very PHP-ish in the sorts of ways that drive me to hateblog about a programming language on a Friday night. It turns out there are people who are totally okay with these design decisions, and I can't help that their subjective tastes are wrong, but that's just how it is.

She mentions three different major issues with the documentation currently in the manual:

  • Non-copypaste-safe cryptography
  • The fact that PHP does not fail effectively when it comes to cryptographic handling
  • The lack of units defined (like for the "length" parameter of hash_pbkdf2)
0 comments voice your opinion now!
pbkdf cryptography manual examples error failure units

Link: http://phpmanualmasterpieces.tumblr.com/post/66426423275/i-cant-spell-pbkdf

SitePoint PHP Blog:
Responsive Images Using Picturefill and PHP
October 10, 2013 @ 10:08:11

On the SitePoint PHP blog there's a new post from Lukas White showing you how to use the Picturefill plugin (Javascript) along with PHP to make responsive images.

One of the key challenges with responsive web design, and a subject of much discussion in recent years, is how to deal with images. Setting a max-width on image elements enables designers to allow their size to adapt to the page dimensions, but in itself that approach can lead to far bigger images being downloaded than are required. [...] You can use a similar approach [to "source sets" of images] straight away and in a cross-browser compatible manner by using Javascript; one such method is the Picturefill plugin. In essence, Picturefill allows you to specify different src attributes for an image, each image file corresponding to a different media query. Thus

The tutorial helps you create an application, powered by the Slim framework and the ImageMagick extension, for the basic structure. He then grabs the Picturefill library and drops them into place. Some sample code is also included showing how to create the HTML structure for the images and the Javascript to handle the switching.

0 comments voice your opinion now!
responsive image picturefill tutorial resolution source set

Link: http://www.sitepoint.com/responsive-images-using-picturefill-php/


Community Events





Don't see your event here?
Let us know!


introduction community opinion version release series voicesoftheelephpant composer interview framework security language list podcast library artisanfiles conference laravel symfony tool

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework