Planet PHP

Syndicate content
People blogging about PHP
Updated: 55 min 59 sec ago

Revamping my development toolchain - Ben Ramsey

2 hours 59 min ago

It used to be that once a year I would take a good, hard look at the tools I used and endeavor to learn something new or change my workflow with those tools. However, I’ve been living the #startuplife for the past two years, so it’s been about three years since I last addressed my development toolchain. I decided to come up for air and take some time this weekend to rectify that by addressing five main areas: my terminal emulator, my shell, my terminal multiplexer, my IRC client, and my color scheme—yes, even my color scheme! In addition, I decided to push out my updated Octopress-powered blog, even though things are still a little rough around the edges.

Switching to iTerm2

I’ve been a long-time user of Terminal.app, but I had been hearing good things about iTerm2. I actually used iTerm (version 1) years ago, but I switched back to Terminal.app for reasons I cannot recall. Nevertheless, iTerm2 has come a long way, and I wanted to take advantage of some of its functionality like split panes, better full-screen support, etc. So, that was the first major change I made to my tools.

Ditching bash for zsh

Bash has been my favored shell since I began using Linux about fourteen years ago. I’d never given much thought to using a different shell, and to be honest, switching shells always seemed a daunting task. I thought I’d have to relearn my way around the shell, and everything I took for granted with Bash would be non-existent in a different shell. Fortunately, this is not true. As it turns out, zsh “can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh” (Wikipedia).

I was able to switch to zsh without ditching my knowledge of bash. As a result, I’ve gained all the advantages of zsh, which include advanced customization and scripting capabilities, while continuing to provide most (if not all) the same functionality and commands I’m used to in bash. I have much more to learn, though, so if you have tips and tricks, please share.

If you’re interested in switching to zsh, I recommend checking out oh-my-zsh. It’s a framework for managing your zsh configuration, and it contains lots of goodies. In addition, there are great posts by Mark Nichols and Jon Kinney that will get you quickly up-to-speed with oh-my-zsh. The latter post has the awesome title “It’s not enough to bash in heads, you’ve got to bash in minds…with ZSH”.

Using tmux instead of screen

Generally, I’ve really only used screen when I started noticing that my connection to a remote development machine was getting sluggish or I wanted to keep a constant connection to IRC, but tmux has opened my eyes to so many more possibilities that a multiplexer can offer. I’ve just only started using it, so I can’t say much about it, but I encourage you to read Hawk Host’s two-part post on tmux.

Moving back to irssi

I used irssi in a screen session for years. Then, I decided I needed Growl notifications from my IRC client. I quit using irssi in favor of Linkinus. I’ve used Linkinus for about two years—together with the IRC bouncer znc for some of that time—but I’ve continued to miss the flexibility and functionality of irssi. On a whim, I decided to switch back to irssi, but it wasn’t without so

Truncated by Planet PHP, read more at the original (another 3132 bytes)

Categories: PHP news

PHPUnit Plugin For Sublime Text 2 - Stuart Herbert

Sat, 02/04/2012 - 20:57

Sublime Text 2 is a new cross-platform text editor that I’ve recently switched to. It’s still in public beta, but already offers better performance (and battery life!) and a better look (fonts that render properly!) than Java-based IDEs such as Netbeans.

One thing it didn’t have was support for PHPUnit, so I’ve made a plugin. It’s available to install via Package Control.

You Need A phpunit.xml or phpunit.xml.dist File

To use this plugin, your project needs to contain either a phpunit.xml or a phpunit.xml.dist file. This file contains all the configuration that needs to be passed to PHPUnit. The plugin searches upwards from your code, and will favour a phpunit.xml file over a phpunit.xml.dist file if it finds both.

If you don’t have one, you need to go and create one now.

How To Use

If you have your code open in a Sublime Text 2 window, right-click inside the window to see what your options are:

  • Test This Class – click this option to run just the unit tests for this class.

    This option appears if the PHPUnit plugin can find your unit tests. It takes the name of your class, and uses the standard PSR-0 transformation to figure out what the name of your test file should be.

    For example, if your class is called ‘Phix_Project\CommandLineLib\CommandParser.php’, the PHPUnit plugin will search for a file ‘CommandLineParserTest.php’ that’s in a folder called ‘Phix_Project/CommandLineLib’.

  • Open Test Class – click this option to open up your tests in Sublime Text 2. If you already have the tests open, this will switch tabs to your tests.

    Again, this option only appears if the PHPUnit plugin can find your unit tests.

  • Run All Unit Tests – click this option to run all the unit tests for your code.

    This option just points PHPUnit at your phpunit.xml or phpunit.xml.dist file.

If you have your tests open in a Sublime Text 2 window, right-click inside the window to see what your options are:

  • Run These Tests – run these unit tests, using the phpunit.xml or phpunit.xml.dist file that the PHPUnit plugin has found.
  • Open Class Being Tested – open the class that these tests are for in Sublime Text 2. If you already have the class open, this will switch tags to your code.
  • Run All Unit Tests – click this option to run all the unit tests for your code.

If you’re someone who prefers keyboard over mouse, then you’ll probably want to run the PHPUnit plugin commands from Sublime Text 2′s Command Palette:

You get the same commands that appear on the right-click menu … the right commands will appear for the file that you’re currently editing, just as you’d expect.

Finally, you can also right-click on your phpunit.xml (or phpunit.xml.dist) file in the Project Sidebar, and run your unit tests using that specific config file.

Helpful Snippets

Like TextMate before it, Sublime Text 2 also has a handy snippets feature, where it can insert a pre-crafted block of text (or, in our case, PHP code) to speed up your coding. I’m collecting most PHP-related snippets in my Additional PHP Snippets plugin (hat-tip to Rob Allen for the inspiration for this), but the PHPUnit plugin includes a few PHPUnit-related snippets to help.

  • phpunit-testcase – will create a new test class for you to fill out.

    I find this handy mostly so that I don’t have to remember which class my test class has to extend :)

  • phpunit-test – will

Truncated by Planet PHP, read more at the original (another 664 bytes)

Categories: PHP news

/dev/hell Podcast Episode #5 - Brian Moon

Fri, 02/03/2012 - 20:12
I was privileged to be invited to be a part of the /dev/hell podcast this week. Thanks to Chris and Ed for having me on. Check it out. And subscribe to their podcast.
Categories: PHP news

Zend Framework application.ini Cheat-Sheet - Mayflower Blog - PHP

Fri, 02/03/2012 - 11:01

With the release of Zend Framework 1.8 came the long awaited component for bootstrapping a Zend Framework application. Many different bootstrapping-solutions became obsolete with Zend_Application.


In the beginning of the framework most developers didn‘t give much thought on bootstrapping. Most of the initialisation work was done directly in index.php, the central starting point of the application. Teams often moved that bootstrapping code to a separate configuration script. The solution worked, but many people wanted a more standardised process for application initialisation.



Continue reading "Zend Framework application.ini Cheat-Sheet"
Categories: PHP news

Another Serious Security Bug on PHP 5.3.9 - PHP Classes

Fri, 02/03/2012 - 07:59
Another Serious Security Bug on PHP 5.3.9 By Manuel Lemos PHP 5.3.9 release was mostly meant to fix a security bug, but it introduced a new more serious bug. PHP 5.3.10 was just released to fix this issue.

Meanwhile Debian Linux maintainers decided to stop enabling the Suhosin extension by default. This extension is used by several Linux distributions to provide protection against present and future security bugs of PHP.

Read this article to learn more about the just fixed bug what you should do to avoid these security issues. You can also learn more what is the current PHP security status and the importance of the Suhosin extension to prevent PHP security problems.
Categories: PHP news

PHP Summit in München - Sebastian Bergmann

Fri, 02/03/2012 - 06:15

This blog posting is in German as the event it relates to is German-only.
Sorry for the inconvenience.

Bei allen PHP-Themen zählt nichts mehr als die Praxis. Deshalb bieten wir unsere Power-Workshops interaktiv und mit intensivem Praxisbezug an. Über die behandelten Themen entscheiden die Teilnehmer mit ihren konkreten Fragen. Anstelle von Frontalunterricht erleben sie die Entwicklung von neuem Code unmittelbar. Mit Augenzwinkern und Spaß erläutern Sebastian Bergmann, Arne Blankerts und Stefan Priebsch Entwicklungsmethoden und Tools und stellen Trends und Konzepte vor.

Der nächste PHP Summit findet im März in München statt. Und das sind die Workshops:

Update PHP: Neue Features und Technologien nutzen Workshop von Sebastian Bergmann

PHP 5.3 und PHP 5.4 überzeugen im Programmieralltag durch eine Fülle relevanter Vereinfachungen. Lernen Sie die innovativen Features und geschickte Einsatzmöglichkeiten der neuen Versionen kennen. Entdecken Sie das Lösungspotenzial aktueller Technologien aus dem PHP-Umfeld (memcached, ZeroMQ …) für Ihre Fragestellungen.

Weg mit Strubbelcode: identifizieren – verbessern – vermeiden Workshop von Sebastian Bergmann

Früher oder später wird unsauber geschriebener Code zum Ärgernis. Nicht nur für den, der ihn warten muss. Änderungen und Erweiterungen können im Extremfall den Code unwirtschaftlich machen. Lernen Sie schlechten Code durch statische Codeanalyse aufzufinden und in test- und wartbaren Code umzuschreiben. Lernen Sie mithilfe der SOLID-Prinzipien, nachhaltig wartbaren Code zu schreiben.

Best Practices – aus dem Alltag für den Alltag Workshop von Arne Blankerts

Natürlich könnte man das Rad jeden Tag neu erfinden. Meist fehlt dafür die Zeit, Spaß macht es auch nicht und Fehler können sich so immer wieder an denselben Stellen einschleichen. Für die vielen alltäglichen Probleme, die nur geringfügig von schon vorhandenen Lösungen abweichen, gibt es clevere Ansätze, die das Leben leichter machen. In einer komplett vom Auditorium gesteuerten Live Session zeigt der Workshop dafür programmatische Konzepte und lädt zur Diskussion über Tools und klassische Fragestellungen ein.

Auf Fehler sicher vorbereitet sein Workshop von Arne Blankerts

Programme und Webseiten enthalten Fehler. Immer. Sie werden sichtbar, wenn Benutzer falsche, ungültige oder unerwartete Eingaben machen, der Zugriff auf die Datenbank plötzlich unmöglich ist oder die Festplatte überläuft. Um solche und andere Probleme sicher abzufangen, gibt es verschiedene Ansätze, die hier vorgestellt und diskutiert werden. Wie man Exceptions richtig anwendet, warum ein eigener Error Handler hilfreich ist und dass Debugging viel mit Sicherheit zu tun hat, vermittelt der Workshop lebendig und anschaulich.

Objektorientierte Programmierung (OOP) in PHP I: Basiswissen Workshop von Stefan Priebsch

Der Workshop klärt die Frage, was es mit der objektorientierten Programmierung eigentlich auf sich hat. Jenseits der bekannten Standardbeispiele führt er praktisch in die OOP mit PHP ein. Dabei werden neben den Grundlagen und zentralen Prinzipien der OOP interessante Features beispielsweise aus der Standard PHP Library (SPL) vorgestellt und ihr sinnvoller Praxiseinsatz vorgeführt. Neben Faktenwissen wird eine Denkweise vermittelt, die es erlaubt, unnötig komplizierte Ansätze von vornherein zu umgehen.

Objektorientierte Programmierung (OOP) in PHP II: Aufbauwissen Workshop von Stefan Priebsch

Der Workshop zeigt Teilnehmern, die mit den Grundlagen der OOP vertraut sind, fortgeschrittene Techniken wie Dependency Injection, abstrakte Klassen, Interfaces und Best Practices für erfolgreiche OOP. Eine Live-Coding-Session macht den Einsatz der vorgestellten Techniken in der Praxis erfahrbar. Außer Faktenwissen zeigt der Workshop, dass gute Lösungen einfache Lösungen sind: Einfache Objekte sind leichter wieder zu verwenden und vermeiden Fehler.

PHP-Anwendungen testen: Basiswissen Workshop von Sebastian Bergmann

Der Workshop vermittelt grundlegende Kenntnisse und Fähigkeiten im Einsatz von PHPUnit bei Unit Tests, Datenbank-Interaktionstests, Edge-to-Edge- Tests und End-to-End-Tests. Sie lernen alles, was Sie über das Schreiben, Ausführen und Organisieren von Unit Tests mit PHPUnit beherrschen müssen.

PHP-Anwendungen testen: Aufbauwissen Workshop von Sebastian Bergmann

PHPUnit clever einsetzen: Die Teilnehmer lernen die besten Praktiken beim Einsatz von PHPUnit und erprobte Strategien bei der Einführung von Testmaßnahmen an vorhandener So

Truncated by Planet PHP, read more at the original (another 6664 bytes)

Categories: PHP news

Excited About PHP Again - Brandon Savage

Fri, 02/03/2012 - 05:23
Ten months ago when I started at Mozilla, I began transitioning away from PHP and into Python and Django. This was inevitable: the Mozilla Webdev team favors Python over PHP in almost every webapp (Socorro is the critical exception). However, over time I had become disillusioned with the direction that PHP was taking. The project [...]
Categories: PHP news

DMS\Filter Library 1.0.1 and Bundle - Rafael Dohms

Fri, 02/03/2012 - 00:08

The past weeks I finally had some time to invest in the DMS library again, so i got busy with a few things. I also had to fix a big problem which had gone unnoticed to me, so i have to thank Mr. Guilherme Blanco for pointing it out.

Sadly this means a BC break, so please follow and make adjustments.

The BC break: ->filter() becomes ->filterEntity()

The reasoning here is simple, PHP still supports legacy from PHP4 meaning a function with the same name as the class is understood as a constructor. This generates a few nasty notices, and it made enough sense to rename the function, making it clear like the other ones.

The DMSFilterBundle

Along with this i had time to work on building a Bundle so you can plug filtering into Symfony 2 just as you would with validation.

Composer support

This bundle is also available on Packagist, making it easy to install, i'll also add the DMS and Filter library as standalones to this soon.

Tags

I finally tagged the releases as 1.0, or rather 1.0.1 as i quickly found a few fixes to put in.

The rest remains, here are the links:

DMS Library: github

DMS Filter Library (sub-tree split): github

DMS Filter Bundle (sub-tree split): github | packagist/composer | knpbundles page (please recommend it if you like it)

© Rafael Dohms for Rafael Dohms, 2012. | Permalink | No comments
Want more on these topics ? Browse the archive of posts filed under PHP.

Categories: PHP news

PHP 5.3.10 Released! - PHP: Hypertext Preprocessor

Thu, 02/02/2012 - 01:00
The PHP development team would like to announce the immediate availability of PHP 5.3.10. This release delivers a critical security fix.Security Fixes in PHP 5.3.10:Fixed arbitrary remote code execution vulnerability reported by Stefan Esser, CVE-2012-0830.All users are strongly encouraged to upgrade to PHP 5.3.10.For source downloads please visit our downloads page, Windows binaries can be found on windows.php.net/download/.
Categories: PHP news

Hey Delta, is it this hard to find an iPad? - John Mertic

Wed, 02/01/2012 - 23:14

So this post is a bit of a rant more than anything, so for the three regular readers of this blog feel free to skip over this post. I promise to make this foray a brief one.

I made a blunder on my flight home from Atlanta to Akron/Canton Airport a few weeks ago; I left my lovely, SugarCRM logo and my name engraved iPad safely in it’s case in the seat pocket of seat 3A. D’oh!

I realized this the moment I got home, and being a bit of a snow storm decided it not prudent to risk life and limb to return to the airport. Calling the airport informing them of this, they took my name and number as said they would ask the Delta desk about this. Being my self driven self, I started tracing the plane, and saw it was doing a CAK-ATL-CAK-ATL-OMA run that day, so figured it would end up in one of CAK, ATL, or OMA ( Omaha for those who aren’t as familiar with airport codes ).

So I went back to the airport at CAK, and they didn’t have it ( but had another iPad someone lost on a plane ), and called OMA, which didn’t see it either. My guess is that it’s in ATL, but low and behold, THERE IS NO NUMBER TO CALL ABOUT DELTA LOST AND FOUND AT ATLANTA. That’s right, nobody to call and ask, nor anyone I could be transfered to that will call there and ask. What do they want you to do? Fill out a web form and hope for the best. Which I did, and all I am left with is hope .

So my call to the blogosphere and twittersphere is this: short of going down to Atlanta and stalking the Lost and Found desk, who can I call to help me.


Categories: PHP news

MicroPHP vs Complicated PHP - Lately in PHP podcast episode 20 - PHP Classes

Wed, 02/01/2012 - 12:54
MicroPHP vs Complicated PHP - Lately in PHP podcast episode 20 By Manuel Lemos Earlier in January Ed Finkler announced the MicroPHP manifesto. It seems to be a rant about against the practices of developers that make PHP development more complicated than it should be. This is one of the main topics discussed by Manuel Lemos and Ernani Joppert in the episode 20 of the Lately in PHP podcast.

They also discuss the final release of PHP 5.4.0 and whether you should upgrade it or not, the repercussion of the PHP Hash Collision Vulnerability, as well the trends of PHP world based on the analysis of the PHP Zeitgeist 2011 initiative.

Listen to the podcast or read the transcript now to learn more in detail about these interesting PHP topics.
Categories: PHP news

Building a RESTful PHP Server: Output Handlers - Lorna Mitchell

Wed, 02/01/2012 - 10:15

This is the third installment in my series about writing a RESTful web service in PHP (the previous entries are about understanding the request and routing it. It is probably the last one but there are a few other things I'd like to cover such as error handling, so I might keep adding to it, especially if I get any particular requests or interesting questions in the comments. So far we've covered parsing requests to determine exactly what the user is asking for, and also looked at routing to a controller to obtain the data or perform the action required. This post gives examples of how to return the data to the client in a good way.

Output Handlers Instead of Views

We'll have as many output handlers as we have supported output formats. The joy of having all the controllers return the data to index.php is that we can then add common output handling to all the data. In our example system, we can remove that ugly print_r from index.php and instead detect which output format is needed and load the relevant view. My code looks like this:

$view_name = ucfirst($request->format) . 'View'; if(class_exists($view_name)) { $view = new $view_name(); $view->render($result); }

The most simple example is a JsonView which looks like this:

  class JsonView extends ApiView { public function render($content) { header('Content-Type: application/json; charset=utf8'); echo json_encode($content); return true; } }

As you can see here, it's pretty simple! We send the Content-Type header first to let the consumer know what's in the response, then we just encode the JSON and echo it out.
To support other formats, you might loop over your array (remember it might be nested – things usually get recursive at this point for something like an XML format) and transform it into the new format. Between two PHP systems, it might be simpler to support s

Truncated by Planet PHP, read more at the original (another 2815 bytes)

Categories: PHP news

A Tool's Tale - Sebastian Bergmann

Wed, 02/01/2012 - 08:30

When Noah Sussman asked me to give a Code as Craft Technology Talk last week when I was consulting for Etsy I immediately said yes. However, I was a bit surprised when the talk was announced under the title "An Evening with Sebastian Bergmann". When I read that title the first time, it was just minutes after Arne, Stefan and I had talked about one of our favourite scenes from "A Knight's Tale":

Chaucer: I'm a writer.

Wat: A what?

Chaucer: A wha- a what? A writer. You know, I write, with ink, and parchment. Geoffrey Chaucer's the name, writing's the game. You've probably read my book? The Book of the Duchess? No? Well, it was allegorical.

Roland: Well, we won't hold that against you, that's for every man to decide for himself.

Just like with a talk that I gave last year, I suddenly had a chain of associations in my head that I just had to follow. And down the rabbit hole I went once more ...

Hi! I have no idea why this talk is titled "An Evening with Sebastian Bergmann". I hope that this evening will turn into an interesting discussion about PHPUnit and all things testing. To break the ice, and to not appear completely unprepared, I came up with the following slides ...

So I recently talked with my friends Arne and Stefan about the movie "A Knight's Tale". Somehow the idea stuck in my head that a variation of that title might be a good idea for a talk of mine. After dismissing "A Fool's Tale" I arrived at "A Tool's Tale". So that's what we're stuck with and what I am going to try right now ...

 

 

 

What I just did was a variation on how Geoffrey Chaucer introduces himself in the movie.

Some time in 2001 I started to work on PHPUnit because I wanted to have something like JUnit for PHP. The initial "port" was completed within one weekend. The code was ugly because I had to emulate exceptions which PHP 4 did not have. On November 27th 2001 I checked the code into cvs.php.net.

A lot has changed since 2001. Hopefully not very many developers are still stuck with PHP 4. As of PHPUnit 2.0, which was released on July 14 2004, the day after PHP 5.0.0 was released, PHP 5 is required to run PHPUnit.

PHPUnit is neither the only testing framework nor the only quality assurance tool for PHP. Over the last years a nice ecosystem of static analysis tools started to grow.

I get this question a lot: why do only Germans work on tools that tell me that my code is bad? I do not have an answer for this, sorry. But the statement is also not true: PHP_CodeSniffer is not developed by a German.

PHP has changed and so the have the tools we use to write and maintain code. In 2006 the PHPUnit code was migrated from CVS to Subversion ...

"/>

Truncated by Planet PHP, read more at the original (another 3752 bytes)

Categories: PHP news

PHP Benelux 2012 – Learning lessons - Rafael Dohms

Tue, 01/31/2012 - 23:12

After hearing about how great PHP Benelux Conferences were I finally made it over to Belgium to check it out, and i was impressed. To catch you up on the new, I moved to Amsterdam last december and thus had the chance of attending the conference which is now 2 hours away on a train ride.

I could not expect less of a wonderful conference when names like Michelangelo van Dam are involved and this was no exception. Its a community conference, planned and organized by community leaders and for community members, this is what makes it so amazing that even without a big name behind it this conference can put up quite a show and bring so many sponsors. As I sat there watching the closing remarks I realized other User Groups and conferences have lots of lessons to pickup from this conference. Let me name a few:

1. Value your sponsors. This was very well executed, during the whole event the sponsors had their logos all over the place and the ones who were present had plenty one on one time with conference attendees. Finally during closing remarks each one was mentioned and with a touch of genius their contributions were described, talk about being thankful.

2. Value your speakers. Who would not want to be a speaker at a conference where you get free belgian beer and chocolates at the end? I know i would, and i'm not even a beer drinker. The amount of care put into the speakers is legendary, pickups, great hotel and i can only imagine what else I did not see myself as a non-speaker.

3. Value your attendees. This should be easy, but lots of conferences fail at it. Good sessions, good venue, good food and infrastructure, just make your client feel confortable. Don't make him want, make everything available to him at the venue and keep him around for more networking and fun.

4. Awesome socials are awesome. The social events around a conference are the crowning jewel to the experience, it allows for much more networking and just plain fun and bonding. This is great for speakers and attendees alike, and is usually the moment where great projects take shape. There is a lot to learn from a chat with Ian Barber about public speaking, he even put it in writing. And there was so much more.

5. Make your attendees pay. Yeah, I said pay. Many conferences think that being "open source" means having a free conference, I say "ppfffff". Charge a reasonable "I'm a beginner developer with low income"-price and put up a great conference using that money, and people will pay. If they do not pay their employers will, if neither of them does, the problem is bigger. Surely the people who will be leaving the conference better then they came in will be willing to pay. This also adds value to the conference, makes it an investment.

6. Value the organizers and your volunteers. There was no single-man effort in the conference, they (from what i saw) worked together like a very well oiled machine. Many times did i see all organizers united discussing something and no man was left trying to solve everything alone. Expand your group, get more people, get volunteer and be sure to thank them, give them their "dues", they will give you their all.

7. Have Fun! Events are always stressful, but you would never guess this from seeing the PHP Benelux crew at work. They just had fun with it, enjoyed, worked, solved solvable problems and apologized for unsolvable ones, what more do we need?

There are probably more lessons to be learnt here, it was a very well executed event, with great speakers, great guests. Coming from Brazil to such a rich network of PHP events is very exciting for me, I love events and now i have multiple large events all around me.

In Belgium I got to see great friends, make new ones, ans most of all realize that it will not be a year before I see them again (yay!). I also picked up quite a few topics to research more and study, as well as being inspired to kickoff new projects and old ideas, the keynotes really did an awesome job to get us inspired.

You can be sure to find me around PHP Benelux 2013, I will be putting out my best to be either a speaker or an attendee, but I'll be there for sure. Congratulations PHP Benelux Crew, it was a wonderful show and a great experience.

© Rafael Dohms for Rafael Dohms, 2012. | "/>

Truncated by Planet PHP, read more at the original (another 1005 bytes)

Categories: PHP news

PECL/mysqlnd_ms: faster slave reads - Internet Super Hero

Tue, 01/31/2012 - 20:59

Why read stale data from an asynchronous MySQL replica (slave)? Fetch it from a local cache instead! Good for the clusters overall load, good for your applications performance. And, possible with PECL/mysqlnd_ms 1.3, the replication and load balancing plugin for PHP MySQL users.

The idea is simple

Any application using asynchronous MySQL replication must be capable of handling stale results read from a slave (replica) that is lagging behind the master. The quality of service that the application needs from the database cluster is low. If an application explicitly states the minimum service quality it needs, the underlying systems can adopt to it. That’s a cool thing, because the underlying systems don’t need to do more work than necessary. In the case of a PHP MySQL user, the first underlying system is the database driver library, which is mysqlnd.

Tell mysqlnd that you can deal with data that is as old as five seconds. Then, mysqlnd can search a matching slave lagging no more than five seconds or even replace the slave access with a TTL-based cache access. Cache? Sure, PECL/mysqlnd_qc, various storage backends including main memory, user-defined, APC and Memcache … have a look at the quickstart.

It exists…

The first step is done. The development trees of PECL/mysqlnd_qc 1.1 and PECL/mysqlnd_ms 1.3 have been de-stabilized. A first, crude approach to make the query cache and replication plugin work transparently together exists.


./configure --enable-mysqlnd-ms --enable-mysqlnd-ms-cache-support

PECL/mysqlnd_ms 1.2 introduced the mysqlnd_ms_set_qos() function for setting the service level required from the cluster.

mysqlnd_ms_set_qos($connection, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL, MYSQLND_MS_OPTION_CACHE, 5);

If you set the service level as shown above, PECL/mysqlnd_ms does never read from a slave that reports itself to be lagging more than 5 seconds behind the master. If no matching slave is found, PECL/mysqlnd_ms picks the master. Additionally, PECL/mysqlnd_ms tries to cache all slave queries for up to 5 seconds. The cache logic is so, that you never get data older than 5 seconds.

The initial cache logic

First, PECL/mysqlnd_ms asks PECL/mysqlnd_qc if the query is already in the cache. If so, PECL/mysqlnd_ms stops searching slaves, continues working and tries to fetch the results from the cache in the following. If fetching from cache fails, which should happen rarely, it reads the result from a master.

In case the query is not cached yet, PECL/mysqlnd_ms searches for all slaves that lag no more than 5 seconds. The cache TTL is reduced by the highest lag found. If, for example, there are two slaves, lagging 2 and 3 seconds behind, the cache TTL is set to 5 - max(2, 3) = 5 - 3 = 2 seconds.

  MYSQLND_MS_OPTION_CACHE Slave lag TTL Slave 1 5 2 3 Slave 2 5 3 2

Then, slave selection continues, for example, load balancing is done. At the end of the chain eventually one slave has been selected. The query is run on the slave and put into the cache for 2 seconds.

How the plugins work together

PECL/mysqlnd_ms does control the cache, PECL/mysqlnd_qc, through SQL hints. PECL/mysqlnd_ms sets exactly the same SQL hints that are also available to the user, as described in the PECL/mysqlnd_qc manual.

/*qc=on*//*qc_ttl=2*/SELECT id FROM test

… and tomorrow: a sneak preview of the new built-in pattern based caching for PECL/mysqlnd_qc 1.1.

Happy hacking!

@Ulf_Wendel 

Categories: PHP news

Plat_Forms 2012 announcement - Gaylord Aulke

Tue, 01/31/2012 - 15:48
Heise and the university of Berlin just announced the next iteration of the Plat_Forms programming contest. This time, the task all teams need to implement will be more "cloudy", not that frontend-heavy. Hopefully, PHP will perform better than in 2011 this time. If you have a team of 3 PHP developers and if you think you can compete with Ruby and Java: registration is open!
Categories: PHP news

Presentation Tips from Benelux - Ian Barber

Tue, 01/31/2012 - 15:28

I had a great time at the recent PHP Benelux Conference in Belgium. There was a real mix of very interesting people to talk to, and I came away from it buzzing with new ideas (and a ridiculously long todo list). Some of the conversations I had during the weekend were around technical presenting at conferences and usergroups, so I thought I'd collect a handful of the tips that were discussed into a post, and use a few of my favourite speakers at the event to illustrate them.

David Zülke

David is the project lead on the Agavi framework, and the founder of the consultancy Bitextender. I've seen David speak a fair few times, and for my money he is one of the very best anywhere at presenting technical information in a clear, digestible way - his talk at PHP BNL 12 about Hadoop being no exception. There are principles at work in his presentations that are worth noting:

Make concepts concrete with examples and demos - When you're talking about a technical subject, you're usually introducing some technology that the attendees are unfamiliar with. Most conference talks are 45min-1hr, including time for questions, so there isn't time to teach a subject - rather you have to focus on inspiring. This means it's vital to mix conceptual, general information with specific, concrete examples and demonstrations so that people can immediately see applied what you have just described to them.

David is brilliant at this, constantly switching between the idea he has introduced, and practical applications. For example, in his PHPBNL12 Hadoop talk he discussed the idea of writing mappers and reducers in PHP, then showed it with actual code examples and a demo. After proving that, he then discussed the value of combiners as a way of reducing data transfer, and then showed that. If he had described them all at once then just showed the final demo, his talk would have been less memorable and less effective.

Structure your talk to repeatedly ask and answer questions - One of the worst sins in a technical presentation is to be boring, but that's exactly what many presenters end up with (and I'm as guilty of that as anyone). This usually happens out of the best of intentions, as the speaker wants to introduce sufficient background before moving on to how the subject of the talk solves the problem. Good talks repeatedly introduce problem/solution pairs, so that there is a constant stream of interesting contrast. David is very good at breaking down a problem in to these steps. In his Hadoop talk he bounced between problem and solution very smoothly:

  • Problem: Big data is big - reading 180GB of a disk will take ~45 mins
  • Solution: Split your IO across many machines
  • Problem: But now you need to coordinate those machines
  • Solution: Mapreduce paradigm

By introducing problems then solutions, he holds the interest of the audience, and naturally splits the information into bite sized chunks.

Rowan Merewood

Rowan is a technical lead in the Sheffield office of consultancy Ibuildings in the UK, and a conference regular. He spoke at PHP Belenux on project estimation.

Care About The Visuals - Presentations, even technical ones, are not about the slides - they're about the speaker. That said, if used effectively slides can make a big difference in how well the audience understands the topic. You don't need a slide for every point, and you definitely don't want to fill your slides full of text, but you should pay attention to making every slide you use, clear, effective, and attractive.

Slides form the back drop, and particularly on a large stage you can be quite a small figure walking in front of a big glowing wall of picture or code. Rowan always puts a great deal of effort into coming up with a theme for his slide design, and it immediately sets the tone for his presentations. Take a look at the day of the dead style figures in his estimation talk, the comics and characters from his legacy code presentation or the Alice in Wonderland theme in his depedency injection talk. Not only are these vi

Truncated by Planet PHP, read more at the original (another 4831 bytes)

Categories: PHP news

High quality JavaScript - Qafoo - PHP

Tue, 01/31/2012 - 12:10
It's time for something big: Qafoo goes JavaScript and from now on provides expert consulting, training and engineering for the full stack of your web application. We warmly welcome Jakob Westhoff, a well-known expert for PHP and JavaScript, in our team.
Categories: PHP news

Phix 0.15 Released - Stuart Herbert

Tue, 01/31/2012 - 10:00

Phix v0.15 is now available from pear.phix-project.org.

This release is dedicated to my Dad, Leslie Herbert, who passed away in December 2011 whilst I was recovering from surgery. He was always encouraging me to spend as much time as possible working on my own software, and I’m sure he’d be happy that his PC has become my new dev box for working on things like Phix.

What’s New In This Release
  • phploc support – the “phing code-review” command now also calculates the size of your component using phploc.
  • subset support – you can now do “phix php-library:init –subset=<role>[,<role> ...]” to create components that only contain some of the different file types supported by the PEAR Installer. There’s also a “phix php-library:removeunusedroles” command if you want to strip unused roles from an existing component.
  • phpunit.xml.dist support – components now use phpunit.xml.dist by default, so that you can put your own phpunit.xml in place if you ever need to override the default settings.
  • src/README.md – we now drop a (hopefully helpful) README file inside the src/ folder to explain what goes where.
  • misc robustness improvements to build.xml files – I’ve made some small tweaks to the build.xml file to try and catch a few error conditions and display helpful messages.
  • internal debugging – “phix -d …” (which has been documented for several release now) enables internal debugging tests inside Phix and its components. It’s mostly there for me to use, but I thought I’d mention it in case you’re testing a patch for phix before sending it to me.

A big thanks to everyone who attended my workshop at PHPNW11 in October for their feedback and feature requests for this release.

How To Install

To install Phix, we have handy one-line install scripts on the Phix project homepage. And I’ve put together a screencast of how to install Phix on Ubuntu. It’s my first ever screencast, so please be gentle :)

How To Upgrade

To upgrade from an earlier release of Phix, please do the following:

sudo pear clear-cache sudo pear upgrade phix/phix4componentdev

Once you’ve upgraded phix itself, don’t forget to go into each of your components, and run

phix php-library:upgrade .

to upgrade all of the skeleton files (build.xml et al) for your component.

What’s Coming In Phix 0.16

Windows support hasn’t happened yet, but I hopefully have a volunteer who is going to look into that during February.

My priority for phix-0.16 is to make it easy to build phix-based components in Jenkins, based on Sebastian’s Jenkins Template. I’m doing this next because I’m not sure how much I’ve got to change things to suit Jenkins, so I’d rather get it done sooner so it’s done and out of the way. (And I promise that I haven’t forgotten docblox support either …)

Our roadmap has all the details.

Categories: PHP news

Roo J Solutions Limited is recruiting - Alan Knowles

Tue, 01/31/2012 - 01:00
Article originally from rooJSolutions blog
Since we have been very busy already this year, I have now almost completed the process of migrating from a Sole Proprietor into a Limited Company. Roo J Solutions Limited is now a registered Hong Kong Company. We are now looking for full or part-time staff (based in Hong Kong). 
Please read the full post for details. 
Categories: PHP news