Site News: Job Postings for the week of 07.25.2010
Daily Dose - Clojure 1.2 Moves Quickly Towards GA
NETTUTS.com: How to Use CakePHP's Access Control Lists
On NETTUTS.com today there's a new detailed tutorial on how to use the access control list functionality that comes with the CakePHP framework.
If you're building a CMS, you'll probably need different user roles'"superusers, admins, users - with different permission levels. Too complicated to code? Enter CakePHP's ACL (Access Control Lists). With the right setup, you'll be checking user permissions with just one line.They talk about what "access control lists" are but shows you an example of one including the database tables and the full scripts for the Users controller, a model to hook into the database and the view for output to the user. They include methods for denying access, checking permissions, and modifying a user's permissions.
Developer.com: 10 Experimental PHP Projects Pushing the Envelope
On Developer.com today there's a new post listing ten experimental projects that are "pushing the envelope" in the PHP languages:
As the saying goes, "Just because you can do something doesn't mean you should." But in the world of programming, stretching boundaries is just part of the fun. The PHP community has never been one to shy away from bending their favorite language more ways than a shopping mall pretzel, and as the ten wild projects introduced in this article indicate, the fervor for experimentation is as strong as ever!Here's their list of the ten projects they see as trying to stretch the language to its limits:
Ask About PHP: Codeigniter: Creating dynamic graphs using JQuery and FusionCharts
On the Ask About PHP blog today there's a new tutorial about integrating the OpenFlashCharts tool into a CodeIgniter application to display data.
I recently upgraded some of my Codeigniter applications that used OpenFlashCharts to using FusionCharts Free, and at the same time incorporated some javascript to allow me to change the graphs dynamically at the client-side. This has greatly improved the usability of my charts and graphs that I pump out. As such, I thought I would share how I did this and hopefully someone will find it useful as well.He walks you through the steps needed to install - putting all of the files in the right places, creating a controller to use the scripts and a view to output the finished chart. A demo of the end result is also included.
Zend Framework 1.10.7 Released
Doctrine MongoDB ODM 1.0.0ALPHA2 Released
Chris Hartjes' Blog: Snakes and Elephants Playing Nice Together: PHPUnit and py.test with Hudson
In the latest post to his blog Chris Hartjes talks about how he got python and PHP working together as a part of his testing with Hudson.
These days, it's becoming increasingly harder to find web applications that are homogenous in terms of the tools they use to Get Things Done. [...] Loosely coupled components, passing messages to each other, is great architecture to try and build if you have both the skills and patience to make it work.His technique combines the testing of PHPUnit for PHP with the Py.test functionality for Python with the continuous integration tool Hudson to run them both as a part of the same build process.
Drupal 7 and Drupal Gardens are on the Way
Symfony Project Blog: Translations (Documentation)
Have a flair for translation and want to help out an open source project in need? Consider helping the Symfony Project with their translation efforts for their manual.
The Symfony2 documentation is written in English and many people are involved in the translation process. First, become familiar with the markup language used by the documentation. Then, subscribe to the Symfony docs mailing-list, as collaboration happens there. Finally, find the master repository for the language you want to contribute for.Full details on what they need help on and where/how to get involved are on the documentation page of the new Symfony 2 website.
PHPBuilder.com: The PHP Content Management/Framework Upgrades in ExpressionEngine 2
On PHPBuilder.com there's a recent article detailing some of the updates in the latest version of the ExpressionEngine product (CMS) from EllisLab.
This popular Web development solution recently took another major step forward with the July 12 release of ExpressionEngine 2.1, the product's first major upgrade in several years. Version 2 sports a number of new features and significant improvements over its predecessor, many of which I'll highlight in this article.He touches on a few of the updates in this latest revision:
- CodeIgniter Integration
- Redesigned Control Panel
- Improved Template Management
- Integrated File Manager and Image Editor
- Accessories (a sort of add-on feature)
You can find out more about ExpressionEngine on its site.
Site News: Popular Posts for the Week of 07.30.2010
- I Am Learning PHP Blog: Do Web-Scripting Languages Really Need OOP?
- PHPClasses.org Blog: Lately in PHP podcast - PHP for Android, PHP 6 canceled, APC in PHP 5.4
- JoomlaBlogger.net: How to understand Joomla templates in five easy steps
- WordPress Blog: PHP 4 and MySQL 4 End of Life Announcement
- Zend Developer Zone: Twice the Amount of Bugs and Twice the Amount of Winners!
- John Hamelink's Blog: Top codeigniter libraries I can't live without.
- Sebastian Bergmann's Blog: Using HipHop for Static Analysis
- NETTUTS.com: 20 Steps to a Flexible and Secure WordPress Installation
- Site News: Job Postings for the week of 07.18.2010
- Nick Belhomme's Blog: PHP 5.3.3 Namespaces
Daily Dose - Check Out the EJB on That JBoss AS
Snakes and Elephants Playing Nice Together: PHPUnit and py.test with Hudson
These days, it's becoming increasingly harder to find web applications that are homogenous in terms of the tools they use to Get Things Done. The ability to build the web front-end of your site using PHP but a critical part that requires asynchronous processing using Node.js is something that is both exciting and, well, practical. Loosely coupled components, passing messages to each other, is great architecture to try and build if you have both the skills and patience to make it work.
For a project at work, I am using PHP (specifically Zend Framework) for the front-end but are using Python scripts run as a cron-job (and also on-demand when statistical corrections occur) to collect raw stats for a variety of sports, and then generate fantasy point totals for the games we run. I'm already using PHPUnit for tests of the front end, and I decided to to use py.test to test my Python scripts.
Setting up tests in Python was pretty simple. Here's one of my test scripts:
PLAIN TEXT PYTHON:- import py
- import baseball_scoring
- def test_batter_empty_data_set():
- expected_points = 0
- test_data = dict()
- test_points = baseball_scoring.batter_points(test_data)
- assert expected_points == test_points
- def test_batter_simple():
- test_data = {
- 'hits': 4,
- 'doubles': 1,
- 'triples': 1,
- 'home_runs': 1,
- 'runs_scored': 1,
- 'rbi': 1,
- 'stolen_bases': 1,
- 'league': 'bluejays2010'
- }
- expected_points = 11
- test_points = baseball_scoring.batter_points(test_data)
- assert expected_points == test_points
- def test_pitcher_empty_data_set():
- expected_points = 0
- test_data = dict()
- test_points = baseball_scoring.pitcher_points(test_data)
- assert expected_points == test_points
- def test_pitcher_simple():
- test_data = {
- 'wins': 1,
- 'losses': 0,
- 'saves': 0,
- 'strikeouts': 7,
- 'complete_games': 1,
- 'shutouts': 1,
- 'league': 'bluejays2010'
- }
- expected_points = 25
- test_points = baseball_scoring.pitcher_points(test_data)
- assert expected_points == test_points
Very similar to tests with PHPUnit, right? So now that I had both PHPUnit tests and py.tests tests (hrm, is there are better way to say that?) to run, I had to figure out how to automatically run them. More specifically, how to get our installation of Hudson to run them.
Getting PHPUnit to play nice with Hudson was relatively easy. I installed the NUnit plugin for Hudson, made sure I installed phpunit, and then I added it's use to my build scripts. However, the strength of Hudson is that with the use of another plugin I could read reports of all those tests. So when things failed, I would not have to look at the console output to figure things out. There's a place in the Hudson config where you can configure this:

Now, I figured that the same thing could be done with py.test. It had an option so that at run-time you could tell it where to put JUnit-compatible test result files. After a little tinkering, I got it to work. First step was adding execution of it to my build script. Here is the latest-and-greatest version of that script:
mkdir /var/www/games-hudson/${BUILD_ID}
cd ${WORKSPACE}/games
/usr/local/zend/bin/php doctrine-cli migrate
cd ${WORKSPACE}/games/tests
/usr/local/zend/bin/phpunit --log-junit=${WORKSPACE}/build/logs/phpunit-results.xml
cd ${WORKSPACE}/games/scripts
/usr/bin/py.test --junitxml=${WORKSPACE}/build/logs/pytest-xmlrunner.xml
cp -R /var/lib/hudson/jobs/${JOB_NAME}/workspace/games/* /var/www/games-hudson/${BUILD_ID}
chmod 777 /var/www/games-hudson/${BUILD_ID}/tmp
rm -rf /var/www/games-hudson/current
ln -sf /var/www/games-hudson/${BUILD_ID} /var/www/games-hudson/current
Next, I then told Huson where it could find the JUnit-compatible files generated by py.test:
So there you have it. Now, when I do a commit and trigger a Hudson build, both my PHPUnit and Python tests get run. And there is output to check, so I don't have to dig through console output to figure things out.
PHPUnit