Archive for Listopad, 2013

On the Qandidate.com blog there’s a new post showing how to set up the PHP profiling tool XHProf/XHGui using Ansible for setup and configuration. Ansible is a radically simple IT orchestration engine that makes your applications and systems easier to deploy.

Once in a while I think about profiling my web applications to see if I can get them to run faster. There are cool tools out there like XHProf and XHGUI to help you do exactly that. And then I remember it took me quite some time to get it all set up… But now that I’ve started using Ansible I decided to document the set up process and share it with you. Today I will walk you through my Ansible role for setting up everything you need for profiling your first PHP script.

He starts with a checklist of things to be sure you have installed first (including XHProf and XHGui) and links to his yml configuration to run a “profiling” command. An example of the result (the XHGui HTML output) is also included.

nette/nette (v2.1.0-RC1, v2.1.0rc)
Nette Framework – innovative framework for fast and easy development of secured web applications in PHP. Write less, have cleaner code and your work will bring you joy.

Are TableGateways too hard to implement in Zend Framework 2? Are they too hard to justify the effort? That’s what I was asked recently during a Twitter conversation. For me, they’re not. For me, they’re well worth the effort. So I’ve written this post to show why they’re not, and how they bring great flexibility, when implemented correctly. In [this post] I’ll set out why they can be a good solution, as well as why not.

He starts from the origins of PHP scripts, back when they were “a collection of files” and not structured under much of a framework. Complexity added the need for this structure, though, including things like design patterns for common tasks. The TableGateway was one of these. He talks briefly about implementing them in Zend Framework v2 (with some gist examples) and some questions to ask helping you determine if they’re “too much” for you app.

On PHPBuilder.com today they have a new article posted sharing a few different methods you can use to do backups of your (MySQL) database and a few handy tricks/tools you can use to optimize it as well.

Every computer system has a backup. Nevertheless, the number of problems caused by a lack of a recent backup is huge. One of the reasons for that may be the fact that the backup process is not entirely automated. So, let’s see how to automate the database backup process in PHP.

There’s three recommendations for the (simple) database backup that can produce a file of the current database contents – mysqldump, mysqlhostcopy and a “SELECT INTO OUTFILE” statement. On the optimization size they suggest mysqlcheck, an OPTIMIZE query to help find trouble spots. There’s a script included at the end showing how these methods can be combined into a simple PHP script, something that can easily be dropped into a cron job to perform every so often.

PEAR’s biggest selling-point -the curation of packages by a governed community – was also its biggest problem. There was no choice, and things moved slowly. If a package stagnated in development, I couldn’t find another actively supported one to solve the same need. In theory, the maintenance of the package could be taken over by someone else, but this didn’t always happen, and contributing patches was not clear or easy.

Ben talks about how, despite the PEAR development’s best efforts, the proposed new package manager (Pyrus and PEAR2) couldn’t keep up. Then, from a discussion had at a conference, the idea of a standards group was formed, the PHP-FIG, and the first standard soon followed, PSR-0 for autoloading. With this in hand and becoming widely adopted, a new tool was created to make it easier to share and install packages with this new standard – Composer.

Composer is what PEAR should have been. Through Packagist, Composer is the democratization of PHP userland libraries. Many libraries in the repository implement similar functionality, but through a show of popularity, the community self-selects the packages that are of the best quality. [...] In just a few short years, Composer has revitalized the PHP community and changed the way we do development.

The SitePoint PHP blog has posted the second part of their series about the creation of a simple comment posting social site based on PHP, MongoDB and jQuery. In this second part they build on the structure from part one and add in posting and “liking”.

In the previous part of the series, we explained the database architecture, post stream design and application flow required for developing our post mechanism wherein the user will be able to post a status, like/unlike other people’s statuses and comment on them. This part of the series will drive you through the coding required to implement these functionalities. We will use the application flow and database structure as discussed in the last article. Don’t forget to download the code from the github repo if you’d like to follow along.

First he shows you how to get new posts added to the database, POSTed to the backend PHP script. He also shows how to insert the contents back into the page and pull out the latest posts. Next up is the like/unlike-ing of the posts, handled by a simple submission to another backend script.

The SitePoint PHP blog has posted the second part of their series about the creation of a simple comment posting social site based on PHP, MongoDB and jQuery. In this second part they build on the structure from part one and add in posting and “liking”.

In the previous part of the series, we explained the database architecture, post stream design and application flow required for developing our post mechanism wherein the user will be able to post a status, like/unlike other people’s statuses and comment on them. This part of the series will drive you through the coding required to implement these functionalities. We will use the application flow and database structure as discussed in the last article. Don’t forget to download the code from the github repo if you’d like to follow along.

First he shows you how to get new posts added to the database, POSTed to the backend PHP script. He also shows how to insert the contents back into the page and pull out the latest posts. Next up is the like/unlike-ing of the posts, handled by a simple submission to another backend script.

On the Aura Framework blog, they continue their look ahead at the coming version of another of the framework’s components, the Aura v2 Router. The Aura framework is a decoupled, modular framework that focuses on minimizing dependencies.

Lately, we’ve been going over the migration of v2 packages from v1. Today, I’ll talk about the updated Aura.Router v2 package. While not an example of extracting a new package from an existing one, it has a couple of features that other routers don’t currently have, in addition to being truly independent and completely decoupled from any other package.

They focus on some of the basics (more detailed information can be found on the package page) of the package’s new features and its focus on routing rather than dispatching. Sample code is included showing it in use. The examples show basic routing, routing by server values and attaching route groups. There’s also a brief section about adding REST routes via an “attachResource” method call.