Feed aggregator

ServerGrove Blog: Symfony2 components overview: Validator

PHPDeveloper.org - Tue, 04/03/2014 - 20:55

The ServerGrove blog has posted their latest in-depth look at one of the many components that make up the Symfony2 framework. In this latest post they cover the Validator component, another well-used part of the framework.

In the first five posts of this series we have been talking about key components for any PHP framework from the point of view of their internals, such as HttpFoundation to abstract the HTTP protocol, HttpKernel to convert a Request into a Response, Routing to map requests to controllers, EventDispatcher to add reusability and extensibility, and Config to load and validate configuration values. This time we'll delve deeper in the user space to describe a component that is for specific apps rather than just for frameworks. Today's topic will be the Validator component.

They start off talking about a common problem in web applications, running validation on incoming data, and how the component can help. The article then gets into the architecture of the component and provides a simple example of it in use (validating an integer range). They talk about some of the built-in validations, the internationalization support and validation on objects, just just simple values. Finally, there's a look at creating custom validations, their example being a simple check on a given "programming language" string.

Link: http://blog.servergrove.com/2014/03/03/symfony2-components-overview-validator

SitePoint PHP Blog: Functional Testing in Symfony2

PHPDeveloper.org - Tue, 04/03/2014 - 19:16

Taylor Ren has written up a new tutorial for the SitePoint PHP blog today walking you through a method for functional testing a Symfony application with the help of Symfony's own "WebTestCase" functionality.

In my previous article, we demonstrated how to load sample data into our Symfony development environment. The test data may not be useful as it stands on its own. When coupled with Functional Testing, however, it becomes a life saver. [...] Functional Testing is different. We don't look at the "correctness" of a single function, which should be verified by a Unit Test, but look at the bigger picture. The question answered by Functional Testing is: Is our app performing well in the sense that it displays the right content, corresponds to a user's interaction, etc?

He shows how to create a simple WebTestCase-based test to fetch the main page of a site, locate a few pieces of information and click on a certain link. Once this test passes, he adds a bit more to the test, checking the data in the page following the click.

Link: http://www.sitepoint.com/functional-testing-symfony2/

HHVM Blog: Tracking Parity

PHPDeveloper.org - Tue, 04/03/2014 - 18:43

On the HHVM blog today there's a new post shows how far along they are with parity with the PHP language based on the tests from a sampling of several large PHP-based projects.

HHVM has a large suite of unit tests that must pass in several build configurations before a commit reaches master. Unfortunately, this test suite passing doesn't tell you if HHVM can be used for anything useful - so we periodically run the test suites for popular, open source frameworks. [...] The frameworks test page is now public, as is the JSON data backing it (which you're welcome to use).

They look briefly at what exactly is tested (latest stable version, with exceptions) and how it all works. The tests are run once an hour and are based on a completely clean build of HHVM in "csv" mode. The results of the tests are automatically pushed into the MySQL+Memcached system reporting system, accessible via the JSON API.

Link: http://www.hhvm.com/blog/3611/tracking-parity

Using MySQL Fabric from any programming language

Planet-PHP - Tue, 04/03/2014 - 18:12

MySQL Fabric is a framework for MySQL Replication high availability, automatic failover and sharding. Technically, a MySQL Fabric daemon monitors a set of MySQL servers and takes appropriate actions upon failure. Clients use Fabric aware drivers to learn about failed servers and shards to distribute queries accordingly. Simple to understand, simple to sell, simple to raise false expectations and simple to fail [, dear Sales]. With the usual blog posts telling only the story of the first three sentences, major parts of the story are covered in silence.

Development preview = announcement of a vision != ready

You first challenge will be to find the documentation for the MySQL Fabric development preview. From the documentation overview page it takes three clicks down to the server side documentation for Fabric:

  1. MySQL Workbench
  2. MySQL Utilities 1.4+ (not the older one!)
  3. MySQL Fabric

You better do not start your search in the MySQL Reference Manual under High Availability and Scalability. Fabric, a command line utility, is well hidden inside the documentation of a GUI tool. Eventually, you may find a download and attempt to install Fabric using an install prefix.

~/mysql-utilities-1.4.1/install/bin # ./mysqlfabric manage start
~/mysql-utilities-1.4.1/install/bin # Traceback (most recent call last):
  File "./mysqlfabric", line 23, in <module>
    from mysql.fabric.services import (
ImportError: No module named mysql.fabric.services
~/mysql-utilities-1.4.1/install/bin # export PYTHONPATH=/home/nixnutz/ftp/mysql-utilities-1.4.1/install/lib/python2.7/site-packages/

80% of the development community is out, true?

Pretty much all blogs and tutorials claim that Fabric aware drivers must be used. According to the manual, such drivers exist for Python and Java only. This covers an estimated 20% of the software development communities. Let’s cry for help:

~#47;mysql-utilities-1.4.1/install/bin # ./mysqlfabric help
Usage: %fabric <group> <cmd> [<option> ...] arg ...

mysqlfabric: error: Error (dispatch() takes exactly 3 arguments (1 given)).
Wrong number of parameters were provided for command (manage help).

~#47;mysql-utilities-1.4.1/install/bin # ./mysqlfabric help help help
Command (help, help) was not found.

Being among the 20% of priviledged Python or Java users you may not bother until you browse the etc/ directory for configuration files. Here you will find something seemingly related to PHP’s Doctrine

~/mysql-utilities-1.4.1/install/bin # ls -la ../etc/mysql/
insgesamt 32
drwxr-xr-x 2 nixnutz users  4096 11. Feb 16:34 .
drwxr-xr-x 3 nixnutz users  4096 11. Feb 16:33 ..
-rw-r----- 1 nixnutz users   119 11. Feb 16:34 default_plugins.cnf
-rw-r--r-- 1 nixnutz users   527 11. Feb 16:34 fabric.cfg
-rw-r--r-- 1 nixnutz users 13132 11. Feb 16:34 mysql-fabric-doctrine-1.4.0.zip

There is something for the PHP driver but it is not documented. Why there is something for a PHP application before the driver part is ‘done done’ may make some scratch their heads.

Putting expectations straight and low

Any project should state what is included and what is not. Fabrics’ vision should be clear and bright. Please, see the slides.

But, Fabric is available as a development preview release only. Core functionality exists. The examples from the manual work for me. But, no other scenarios do. For example, mysqlfabric group import_topology lacks documentation and mysqlfabric group promote blog_repl fails for me.

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

Categories: Open Source, PHP Community

Voices of the ElePHPant: Interview with Paul Jones

PHPDeveloper.org - Tue, 04/03/2014 - 17:23

The Voices of the ElePHPant podcast has released their latest episode in their community interview series. In this new episode Cal Evans talks with Paul Jones (lead developer on the Aura PHP framework).

They talk some about Aura project and the current status, including the work on the version 2 components and what's to come (recombining v2 packages back into the vs framework). They also talk about Paul's book Modernizing Legacy Applications.

You can listen to this latest episode either through the in-page player, by downloading the mp3 or subscribe to their feed.

Link: http://voicesoftheelephpant.com/2014/03/04/interview-with-paul-jones/

Community News: Packagist Latest Releases for 03.04.2014

PHPDeveloper.org - Tue, 04/03/2014 - 16:08
Recent releases from the Packagist:

Community News: Latest PECL Releases for 03.04.2014

PHPDeveloper.org - Tue, 04/03/2014 - 15:04
Latest PECL Releases:
  • solr 2.0.0b - Support Solr version 4.0+ - Added support for retreiving Solr Server system information through SolrClient SolrClient::system() - Support for softCommit - Suppport for expungeDeletes - maxSegments for commit is deprecated - Added escape character / as per Solr 4 it is reserved for REGEX - Disabled warnings for connection errors, SolrClientException is thrown - SolrClientException messages for connection errors are more meaningful indicating error messages and codes - API changes for: SolrClient::commit($maxSegments = 0, $softCommit = false, $waitSearcher = true, $expungeDeletes = false) SolrClient::optimize($maxSegments = 1, $softCommit = false, $waitSearcher = true) SolrClient::addDocument(SolrInputDocument &$doc, $overwrite = true, $commitWithin = 0) SolrClient::addDocuments(array &$docs, $overwrite = true, $commitWithin = 0) - Several Bug Fixes Warning: PECL Solr >= 2 is not compatible with Solr Server < 4.0

  • APCu 4.0.4 - Fix deadlocking due to destroyed locks - Fix various compatibility bugs

  • krb5 1.0.0 - [CLEANUP] Remove bundled kadmin headers, drop support for mit-krb5 <1.8 - [FEATURE] Support use of the krb5-config tool to determine library paths - [CLEANUP] Remove KRB5CCache->setConfig method as this is no longer supported by libraries - [BUG] Fix null-deref in isValid for uninitialized KRB5CCache

  • xdebug 2.2.4 Fri, Feb 28, 2014 - xdebug 2.2.4 = Fixed bugs: - Fixed bug #785: Profiler does not handle closures and call_user_func_array well. - Fixed bug #963: Xdebug waits too long for response from remote client - Fixed bug #976: XDebug crashes if current varibles scope contains COM object. - Fixed bug #978: Inspection of array with negative keys fails - Fixed bug #979: property_value -m 0 should mean all bytes, not 0 bytes - Fixed bug #987: Hidden property names not shown.

  • swoole 1.6.11 - Disable by default async_mysql - Disable by default sockets - Added event onWorkerError - Added event onWorkerStart for task_worker - swoole_server->task can assign worker_id - swoole_server->set() save params to swoole_server::$setting - swoole_client->send will check data length - swoole_server->connection_info for udp

  • mongo 1.5.0alpha1 ** Bug * [PHP-722] - Segfault when passing null value to MongoCollection::find() and unclear other conditions are met, inaccurate error message * [PHP-796] - Modifying MongoDate internal properties evilness * [PHP-813] - IS_SCALAR_*() doesn't account for resources * [PHP-815] - MongoCursor ctor doesn't validate the MongoClient object * [PHP-833] - Add the MongoClient::killCursor method to kill a cursor on the server on 64-bit platforms * [PHP-835] - Driver interprets 'err' property as MongoCursorException * [PHP-848] - Invalid read in master * [PHP-882] - mongo_connection_get_server_version memleaks * [PHP-883] - php_mongo_dbref_create() doesn't handle MongoId values * [PHP-888] - DBRef refactoring broke BC for $id parameter handling * [PHP-902] - Segfault when unregistering broken server * [PHP-949] - ensureIndex() creates wrong names * [PHP-955] - Switch the default mongo.native_long to 1 for 64bit platforms * [PHP-981] - Empty document should not throw exception ** Improvement * [PHP-578] - No need to call ismaster 2times * [PHP-705] - Throw exception when overflowing message size in OP_INSERT batches * [PHP-708] - WriteConcern failure exception should include the entire GLE document * [PHP-712] - findAndModify returns empty array when nothing is found * [PHP-774] - Deprecate the protected method MongoCollection::toIndexString * [PHP-807] - Rewrite to_index_string to use smart_str and a real C function * [PHP-812] - Remove unused MongoDBRef::$refKey and MongoDBRef::$idKey * [PHP-837] - Handle cursor IDs for return with MongoCursor::info on 32bit platforms * [PHP-851] - Add MONGO_HAVE_* constants and make sure MINFO contains this too * [PHP-880] - New write operation method for insert, update, remove * [PHP-886] - Add support for secondaryAcceptableLatencyMS * [PHP-903] - Improve the Stream Notification API * [PHP-941] - Throw MongoConnectionException on stream failures * [PHP-942] - Throw MongoDuplicateKeyException on duplicate key errors * [PHP-971] - Remove mongo.native_long for 32bit platforms * [PHP-990] - Implement Batch Write API ** New Feature * [PHP-819] - Add Mongo[DB|Collection]->[get|set]WriteConcern() * [PHP-831] - SASL Support (SASL Plain) * [PHP-832] - SASL Support (SASL Kerberos) * [PHP-861] - Add maxTimeMS() method to MongoCursor to configure the maximum time a query can take * [PHP-868] - Method to check if string is a valid ObjectId * [PHP-873] - Support the MONGODB-X509 authentication mechanism * [PHP-875] - Add support for cursor for aggregation * [PHP-876] - Make the driver check for the server version upon connection * [PHP-923] - Drivers should only talk to servers with overlapping wire versions * [PHP-944] - Support $out aggregation pipeline operator * [PHP-951] - Provide API for getting latest server version or isMaster response in driver * [PHP-962] - Create constants for additional binary data subtypes * [PHP-965] - Documentation for MongoId::isValid() ** Task * [PHP-657] - Add deprecation notice to MongoCursor::slaveOkay * [PHP-714] - Convenience macro for getting mongoclient* * [PHP-786] - Sort out includes * [PHP-809] - Deprecate use of "safe" all over collection.c * [PHP-844] - driver must authenticate before calling isMaster() * [PHP-845] - Ability to use different SPN on the driver for Kerberos Authentication * [PHP-983] - Change nUpdated to nMatched in bulk api results ** Sub-task * [PHP-763] - Create prototypes for MongoClient and Mongo classes * [PHP-794] - Remove 'fd' property of MongoCursorException * [PHP-797] - Deprecate public properties * [PHP-798] - Rename "timeout" to "socketTimeoutMS" in $options * [PHP-804] - Deprecate Mongo::connectUtil * [PHP-818] - Deprecate "Mongo" in favour of MongoClient. * [PHP-824] - Deprecate the "wtimeout" option in crud operations for wTimeoutMS

Walking the London LOOP - part 2

Derick Rethans - Tue, 04/03/2014 - 11:23
Walking the London LOOP - part 2

Back in October 2013, Morag and I started walking the London LOOP - with section 1. It took nearly four months before we embarked on the second section. The delay was mostly caused by the short days and the terrible weather we have had during the winter. But with the Sun returning and the days getting longer it was time to do part 2: Bexley to Jubilee County Park. We originally intended to do the walk on February 15th, but all the trains towards Kent were buggered due to lots of falling trees caused by the latest storm — hence our second attempt last Sunday. Why I thought it was a good idea to do this right after the PHP UK Conference is a bit of a mystery to me still.

Of course, the travel to the start of the walk was not as straightforwards as it could be. With lots of engineering work and bus replacement services. We ended up taking the train to Barnehurst and bussing it to Bexley—much better than the route that was suggested by National Rail Inquiries: train from Charing Cross to Plumstead, bus to Dartford, and then the train back to Bexley.


From Bexley startion we crossed under the railway and headed South. Just before getting to the river Cray, we walked through some woodland where a fair amount of trees had not survived the winter storms. Joining the river after a mile or so we noticed that it was still very high, and rather fast flowing. In fact, it was so high that many of the paths were either flooded—or very muddy. The muddy path opened up into the Stable and Footscray Meadows and a very lovely bridge, the Five Arches, crossing over the river Cray.

loop2-d36_4585.jpg loop2-d36_4589.jpg

I think there was a bit more water in the meadows than there usually was. Or perhaps the locals tried to create an extra lake. In any case, there was no dry way out of the meadows into the direction we had to be going. The photo to the right just points out how much water we had to wade through. I estimate it was about 3 inches deep.


Past the meadows and All Saints Church we stopped in Sidcup for lunch. Although the route goes past a pub, we decided to skip and instead just pick a cafe in Sidcup itself. But not before we encountered this friendly horse.

Sidcup itself seems like a little village with not much going on, but lunch at Urban Food was decent. After filling up we continued the walk by finding Sidcup Place and crossing the A20 into Scadbury Park.


Scadbury Park is rather large and a local nature reserve. It is also old and has a ruined moated manor in the middle, which was owned by the Scathebury family. The LOOP as mapped on OpenStreetMap had the route go past the manor, but I found that was incorrect as shown by the sign posts on the route.

loop2-d36_4616.jpg loop2-d36_4631.jpg

From Scadbury park we crossed into Petts Wood, or rather perhaps it should be called the Petts Mud Flats as there was nearly no space without mud — some times up to half a foot deep. An indication of the amount is visible in the image to the right. I don't think I've ever had this much mud on a walk actually.


This meant that we were a bit delayed and we would just miss the train home from Petts Wood station. When coming out of the woods we crossed multiple sets of train tracks. The section as shown on the left is just before the end point of second section in the Jubilee Country Park.

The weather was colder than the first section, but that was no surprise as it is February. At around 8°C there was a fair bit of wind, but we kept it dry.

For the full photo series of the LOOP, see my Flickr set.

Categories: Open Source, PHP Community

Simon Holywell: HHVM vs Zephir vs PHP: The showdown

PHPDeveloper.org - Mon, 03/03/2014 - 20:38

Simon Holywell has posted what he calls a "showdown" between HHVM, Zephir and PHP comparing various benchmarks (based on a Mandelbrot Set fractal).

Since its inception the slow running speed of PHP has been widely publicised and over the years there have been a number of improvements. [...] It has become more interesting recently however with three projects looking for improvements in different ways. The core has adopted the Zend OPcache for future versions of PHP, Facebook has been working on a just in time compiler called HipHop VM and the team that brought us Phalcon framework have created Zephir.

All of these projects have chosen to tackle the issue of PHP's speed via different avenues. It has therefore left one simple question - who's making the biggest improvements? Who's the fastest?

He briefly introduces the "contenders" for those not familiar with them and gets right into the benchmarking process. He shares the link to the tests he used and a few notes about the HHVM setup that could account for lower numbers. He shares his results in a few graphs or you can grab the CSV data yourself and parse it. The entire setup is also over on GitHub if you'd like to just check that out.

Link: http://simonholywell.com/post/2014/02/hhvm-vs-zephir-vs-php-the-showdown.html

SitePoint PHP Blog: Installing PHP Extensions on Nitrous.io

PHPDeveloper.org - Mon, 03/03/2014 - 19:45

On the SitePoint PHP blog Bruno Skvorc has posted a new tutorial showing you how to get PHP extensions installed on Nitrous.io, an online environment combining an IDE and PaaS hosting.

Inspired by a comment on my previous article, I realized Nitrous was still a bit too complicated to customize properly. In this tutorial, we'll glide through installing cURL and Phalcon on a Nitrous.io PHP box.

He continues on from his previous article and shows how to detect cURL support and how to build it from the PHP source into an extension. He helps you get the source for the older PHP version Nitrous.io has installed and the commands you'll need to build the extension. With it installed and enabled in the php.ini, he also installs the Phalcon extension.

Link: http://www.sitepoint.com/installing-php-extensions-nitrous-io

Magento vs. X-Cart (+ Screencast)

Planet-PHP - Mon, 03/03/2014 - 19:00

It’s been a while since I did my last Magento comparison, and the sad thing is: Nothing much has changed since then. Magento still looks and works the same, and in this industry standing still is the same as moving backwards.

True, Magento has moved on from version 1.7 to 1.8, but that was mostly rolling out bug fixes. And it still has some serious flaws which haven’t been addressed. Any real progress seems to be stalled while awaiting for Magento 2.0, the version rumoured to be heavily influenced by eBay, its new owner. This should be a real leap forward and should make Magento the top dog again. But the fact remains, 2.0 is still far from being ready.

And then there is X-Cart 5. While it technically follows up on X-Cart 4, it is a rebuild version of this decently successful shopping cart. Basically X-Cart 5 is to X-Cart, what Magento 2.0 should be be to Magento 1.8. And with X-Cart having a rapid development cycle, this could mean X-Cart 5 takes the lead – at least for small- and medium sized business, which is where X-Cart is at its best.

Continue reading %Magento vs. X-Cart (+ Screencast)%

Categories: Open Source, PHP Community

Functional Testing in Symfony2

Planet-PHP - Mon, 03/03/2014 - 19:00

In functional testing, we don’t look at the “correctness” of a single function, which should be verified by a Unit Test, but look at the bigger picture. The question answered by Functional Testing is: Is our app performing well in the sense that it displays the right content, corresponds to a user’s interaction, etc? This tutorial will focus on Functional Testing in our pre-built Symfony app.

Continue reading %Functional Testing in Symfony2%

Categories: Open Source, PHP Community

Ross Tuck: Persisting Value Objects in Doctrine

PHPDeveloper.org - Mon, 03/03/2014 - 18:11

Ross Tuck has submitted a new article he's posted about persisting value objects in the popular PHP database storage and object mapping library, Doctrine. Value objects are immutable objects that " follow value semantics rather than reference semantics".

I've been using more and more Value Objects in my applications over the last year, primarily with Doctrine ORM. Value Objects are an extremely powerful technique and I've been impressed with how much they can clean up a codebase. One of the main questions I've had when starting with Value Objects is how to persist them with Doctrine. This post attempts to create a reference for all the different persistence techniques I've seen so far.

You'll need to be familiar with Value Objects and Doctrine before starting (it's not an "intro to Doctrine" article). His example sets up an "IPRange" and an "IPAddress" that are stored in a "Server" instance. He talks about mapping the value object to the database and the getter/setter to do the work. He also touches on DBAL types, working with multiple columns in the entity and the "promised land" of embeddables. He finishes off the post looking at collections of entities and some of the other options to what he's shown (including serialization).

Link: http://rosstuck.com/persisting-value-objects-in-doctrine/

/Dev/Hell Podcast: Episode 40: Poly Life Mentoring

PHPDeveloper.org - Mon, 03/03/2014 - 17:16

The /Dev/Hell podcast, hosted by PHP community members Ed Finkler and Chris Hartjes, has released their latest episode - Episode 40: Poly Life Mentoring.

The big four-oh hits us, this time with our special Fictive Kin friend Sean Coates. We talk lots about deploying web applications in various languages, the impact Composer has had on PHP development, formal and informal mentoring, and how to get accepted to speak at conferences.

They also talk about a wide variety of other subjects in this edition including RVM+Bundler, Composer+Packagist, Flash, PHPMentoring.org and Webshell. You can listen to this latest episode either through the in-page player or by downloading the mp3 directly. If you like what you hear, consider subscribing to their feed for more great episodes.

Link: http://devhell.info/post/2014-02-28/poly-life-mentoring/

Community News: Packagist Latest Releases for 03.03.2014

PHPDeveloper.org - Mon, 03/03/2014 - 16:09
Recent releases from the Packagist:

Unit Testing by Example @ ConFoo

Planet-PHP - Sun, 02/03/2014 - 23:38

I gave a talk last week at ConFoo. It was very well received and I had some amazing feedback.

One person told me that he has been trying to write tests for two years but never had any success. With the advice gathered in my talk, he was able to write a few tests and now has the confidence to write a lot more. Another person told me that he liked my step-by-step approach that allowed less experienced developers to learn and advance, rather than being thrown straight into Test-Driven Development (TDD) and then fail.

This was exactly my intention. Most  testing talks and blogs that I saw until now are not beginner-friendly. They are inflexible, preaching only 100% coverage, “TDD or go home” and being perfect from day one. They completely ignore the human factor. Beginners are turned off by that, which means that instead of having some tests, certain projects have absolutely none. Also, too many talks focus on the testing API rather than on how to approach testing in a project.

I taught people to start writing tests where they are easy to write. Once people wrap their heads around the basics, I show the next steps until I eventually get them to TDD. I want people to feel that it’s ok to practice, that they can’t be perfect from the beginning. I want them to have the confidence to start, or to try once again if they were previously unsuccessful. I want more people to write tests. I definitely convinced the 100 or so people who came to my talk.

I will definitely be giving this talk again at other events.

Categories: Open Source, PHP Community

Community News: Packagist Latest Releases for 03.02.2014

PHPDeveloper.org - Sun, 02/03/2014 - 16:03
Recent releases from the Packagist:
Syndicate content