 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Lorna Mitchell: Simplest PHP Generator Example
by Chris Cornutt May 23, 2013 @ 10:31:02
On her blog Lorna Mitchell has posted an example of a basic generator written in PHP, a feature of the upcoming PHP version 5.5.
I really like the generators feature that's arriving in PHP 5.5, and since we're now into release candidate releases, it's actually not that far away. I've been speaking on this topic and I thought I'd share my trivially simple code example from my slides.
She includes an example of a very basic generator using the new "yield" keyword and how to implement it in a simple foreach loop. There's also a little talk about when is a good time to use generators in your applications (two examples: complex number calculation and working with large data sets a chunk at a time). For more information on how these generators will work, check out this page in the PHP manual.
voice your opinion now!
generator simple example introduction manual
Rob Allen: Simple logging of ZF2 exceptions
by Chris Cornutt April 25, 2013 @ 10:31:40
In this new post to his site Rob Allen shows you how to implement a simple logging method for catching exceptions in your Zend Framework 2 application.
I recently had a problem with a ZF2 based website where users were reporting seeing the error page displayed, but I couldn't reproduce in testing. To find this problem I decided to log every exception to a file so I could then go back and work out what was happening. In a standard ZF2 application, the easiest way to do this is to add a listener to the 'dispatch.error' event and log using ZendLog.
He uses an event listener to attach a service that contains a "logException" method. This method uses the ZendLog component to write out the error message to a local log file including a backtrace of where the issue occurred.
voice your opinion now!
simple logging exception handling service event listener tutorial
Systems Architect: Performance benchmark of popular PHP frameworks
by Chris Cornutt April 24, 2013 @ 12:04:31
On his site today Lukasz Kujawa has a post that compares some performance benchmarks of several popular PHP frameworks including Slim, CodeIgniter, Laravel, Symfony2 and Zend Framework 2.
There are many assumptions around performance of different PHP frameworks. I frequently hear strong opinions about superiority X over Y in this context. There are companies writing new PHP frameworks from scratch because available solutions are too slow for them. What does it really mean? Does the framework performance matters? Before answering this questions lets check how slow is your framework!
He took the "quick start" projects provided for each of the examples and ran some tests with the Apache Benchmark (ab) tool against EC2 instances, all configured the same way. The results weren't overly surprising with Slim beating the others hands down (it's a micro-framework after all) and Kohana and CodeIgniter coming in second and third. The frameworks with more overhead like Zend Framework and Symfony ranked some of the slowest.
voice your opinion now!
benchmark framework test apachebenchmark ab results
Vance Lucas: Valitron The Simple Validation Library That Doesn't Suck
by Chris Cornutt March 05, 2013 @ 11:43:24
Vance Lucas has created a "validation library that dosen't suck" and posted about it to his site - his Valitron library.
Valitron is a simple, minimal and elegant stand-alone PHP validation library with NO dependencies. Valitron uses simple, straightforward validation methods with a focus on readable and concise syntax.
He created the library because of frustration with other tools that had (sometimes major) dependencies on other packages. All he wanted was something lightweight and easy to use that was flexible about how it handled its validation rules. Valitron lets you apply a validation (like "required") against multiple fields in the provided data and includes checks for things like length, valid IP, active URL, alpha-numeric, date format and regular expression match. You can also add custom validation rules via a callback/closure.
voice your opinion now!
validation library valitron simple dependencies
PHPMaster.com: Simplifying Test Data Generation with Faker
by Chris Cornutt February 19, 2013 @ 12:09:02
In a new post to PHPMaster.com today, Rakhitha Nimesh takes a look at Faker, a tool that can be used to generate random test case data as a part of your workflow.
Testing is an iterative part of the development process that we carry out to ensure the quality of our code. A large portion of this entails writing test cases and testing each unit of our application using random test data. Actual data for our application comes in when we release it to production, but during the development process we need fake data similar to real data for testing purposes. The popular open source library Faker provides us with the ability to generate different data suitable for a wide range of scenarios.
Faker uses built-in data providers like "Person", "Company", "DateTime" and "UserAgent" to give you randomized output from the data sets you define. Code is included showing how to create the provider in your objects, extending the correct provider and making a request for a property. A real-world example is also included about testing an email marketing engine for address, title, name and content. There's also a little bit added at the end showing how you can increase the randomness of the results returned by "seeding" the Faker engine.
voice your opinion now!
test data generation faker library object provider tutorial
|
Community Events
Don't see your event here? Let us know!
|