Silvan Muhlemann has posted about the unit testing that tillate.com does for their releases - the whole process from start to finish.
For now over three years we are working with unit tests. I'd like to share some of those experiences. As we have two frameworks in place for our website, I can compare two different strategies for unit tests.He talks about their choice of SimpleTest, their test monitoring, CruiseControl and their "if it doesn't pass, you can't release it" mentality to keep their site as bug free as possible.
Matthew Turland has posted about his experience working with a Windows XP system trying to get PHP 5.2 and SQL Server 2000 to play nicely together:
Recently at work, I was tasked with finding a method to retrieve data from a third-party SQL Server 2000-based system into our own MySQL-based application. It's worth noting that both system are behind their own firewalls and I was trying to bear security in mind as I did this.Some highlights of his work included using GoToAssist to get to the system, using EMS SQL Manager to work with the SQL server itself and some of the PHP code he "threw at it" to grab the info he needed from the database (with the PDO drivers).
Here is some news about data structures available in SPL:
Here is an example of a simple but task scheduler using SplPriorityQueue:
<?php $q = new SplPriorityQueue; $q->insert('a', 1); $q->insert('b', 4); // ... $q->insert('z', 2); foreach($q as $task) { // .. process task .. echo $task."\n"; // ... add new tasks .. if ($task == 'b') { $q->insert('c', 3); } } /* Output: * b * c * z * a */ ?>This implementation is really efficient as the underlying data structure of SplPrioritiyQueue is a Heap, which allows insertions and extractions in O(log2(N)).
Padraic Brady is up to part seven of his blog creation (with the Zend Framework) series, tracking his development paths and though processes along the way. This new part of the seres looks at using Zend_Acl for user management and changing up some of the style of the site.
We previously covered how to authenticate an author to the blog, but we still have nothing ensuring only authenticated authors can access the new Administration Module. This is the domain of Zend_Acl, an implementation of an Access Control List system which limits access to resources by the roles assigned to a user.He starts by helping you understand access control lists including roles and privileges. He plans out the different roles that he wants the application to have first (always a good first step) and then implements them in a class extending the Zend_Acl component. He wraps this all in a front controller to make it easy to use.
He also tosses in a bit there at the end about CSS and styling to handle the forms for login and the administration piece of the blog he created earlier.
Sebastian Bergmann has pointed out something obvious to anyone that's ever tried to work with unit tests in PHP - there's just not that much support for it. The software is there and waiting to be used, but too many developers just don't take advantage of it.
Maybe it took the PHP community a little longer to realize the importance of testing. But now that we know how to build applications that "just work", are fast and scalable, as well as secure, a big topic in the PHP community right now is to implement processes and use techniques that help us assure that the software works correctly throughout the its lifecycle.He points to some comments made at a recent panel discussion about PHP and testing, the proliferation of frameworks for the language and the things that have no name that developers use every day to make their code "just work".
On the SaniSoft blog today, Tarique Sani has a quick hack for CakePHP users needing to transition over from the deprecated vendor() call - import().
Use of vendor() function to load third party libs in CakePHP has been deprecated for some time now... It has been replaced with the more generic App::import() the usage is simple.There's also a little trick you'll need to know for files with underscores (drop it and replace with an uppercase) and how to get it to be a bit more flexible and recognize vendor files in subdirectories or ones differently named.
Whether you’re an enterprise developer working in a large shop or setting up a blog for yourself, you’ve almost certainly been tasked with keeping your development code in sync with some type of stable release. Whether a project is big or small, you still need to ensure that the core code you work with remains consistent. This article will walk you through the development of an Adobe AIR and AJAX application used to synchronize the modules of a site developed in Drupal, the popular free and open-source content management system used in thousands of sites across the Internet.
Whether you’re an enterprise developer working in a large shop or setting up a blog for yourself, you’ve almost certainly been tasked with keeping your development code in sync with some type of stable release. Whether a project is big or small, you still need to ensure that the core code you work with remains consistent. This article will walk you through the development of an Adobe AIR and AJAX application used to synchronize the modules of a site developed in Drupal, the popular free and open-source content management system used in thousands of sites across the Internet.
That's how this new post on the PHP in Action blog starts this morning. The one thing that he wants is enumeration support in PHP. He shows how it can currently come close with a "roles" system:
Useful examples I've encountered in web programming are states or stages in a process and user roles. Another kind of example is one I used in PHP In Action: an authorization system with three fixed roles or categories of user: regular, webmaster and administrator.He sets up an example class that sets constants for the different access levels rather than just relying on strings to handle it (which, as he points out, could very easily be misspelled and not throw any kind of error) .
This is part one of the quick review of the book “ for Effective MySQL Management” and the phpMyAdmin software.
This article/review is not just another review about phpMyAdmin, but more some information about features I haven’t used during the last years of PHP/MySQL web development.
PMA is a full featured tool to administrate your MySQL database server via a web browser. While the functions are almost unlimited, it’s also a powerful tool to maintain the database content even for less experienced users.
It’s already a year ago (or more) that I got the book “Mastering phpMyAdmin” as a present/reward for contributing some snippets on weberdev.com. Finally I found the time to read (most of) the book during a vacation. The book is great for webmasters using phpMyAdmin (PMA) the first time and also more advanced users. The book covers the installation, basic database interactions using PMA like simple INSERT or SELECT commands and also advanced features like the relational system provided by the phpMyAdmin software. (more…)
Akash Mehta shares a helpful hint in this new post to the Developer Tutorials Blog today - testing out PHP code via the command line PHP binary.
Thankfully, PHP provides the interactive shell, allowing you to test out PHP interactively with immediate feedback. Here's how to take advantage of this mature feature of PHP.With the help of the "-a" flag on the command line, the PHP binary will hand you an environment where you can code PHP and instantly see the results. He does mention a few quirks that make it different than working with PHP through a web server, namely moving in and out of code blocks and remembering to finish out with a semi-colon when the line is done.
Truncated by Planet PHP, read more at the original (another 4445 bytes)
That's it really. A cute search box that's "self contained" inside a PHP function so it's extremely convenient to display. What can I say? I got bored... [Link]
For now over three years we are working with unit tests. I’d like to share some of those experiences.
As we have two frameworks in place for our website, I can compare two different strategies for unit tests.
In our homemade legacy framework we were using SimpleTest. Mainly because I read PHP|Architect’s Guide to PHP Design Patterns and Simpletest was Jason’s framework of choice.
We have a cron job running which runs all tests every hour. The results of the tests are being shown on a page. The results are also displayed in Nagios.
I've started looking at forking ExtJS, after some considerable thought, I'm pretty close to the concluding that forking ExtJS is really option left, to retain the investment I've already made in it..
So, as I have a Zip file of 1.1.1 and it explicitly says that the Javascript code is Licensed under LGPL, (not ifs/ no but's) - I'm slowly putting the code into my subversion repo under www.akkbkhome.com/svn/extjs1 (*I'm looking at extjs1.1.1 as I have been using it and tend to prefer it, but there is nothing in the discusion below that precludes anyone helping/leading with the last extjs2 version that was released)
Now if this actually becomes a full fork (most forks fail BTW), It will need a bit of work, so If anyone is interested in helping out. I've no idea where this could go. But this fork ain't changing the license no-more...
The planI think there's quite a few things to do here... so Ideas or contributions.. -- feel free to email me, or just comment on this post. - At worst, it could form the brainstorming for anyone else actually doing this. (If you want to comment on if/should this be done - do it on my previous post, otherwise I will delete the comment)
The Code
The Project
Truncated by Planet PHP, read more at the original (another 2564 bytes)
I just found out a very strange PHP feature by browsing the PHP-GTK2 API with the Reflection classes : spaces can be used in some alien places, like variable names.
But the doc says you can't !Well, try this in PHP 5.2.5, for instance:
I'm currently working about equally in PHP and Java. I can't say I've fallen in love with Java. But Java does have a feature or two that would be useful in PHP. One of them is the Enum (enumeration, that is), which is traditional in some languages and DBMSes (including MySQL) and was introduced in Java 1.5 (or is that 5.0? I'm sure they do that just to expose people like me as Java amateurs).
Enumerations are useful when a variable can have one of a given number of values. Actually useful examples I've encountered in web programming are states or stages in a process and user roles. Another kind of example is one I used in PHP In Action: an authorization system with three fixed roles or categories of user: regular, webmaster and administrator.
If we represent the roles as text strings, we risk getting our tests wrong: if ($role == 'amdinistrator')...
The only problem is that the word administrator is misspelled, so the test won't work.
This can be solve by representing the values with named constanst instead. Using class constants in PHP 5: class Role const REGULAR = 1; const WEBMASTER = 2; const ADMINISTRATOR = 3; ...
Now we can do this instead:
We won't get away with any misspellings here; using an undefined class constant is a fatal error. Compared to global constants, this may be easier to figure out, not least because we know where the constant is defined (inside the Role class) just by looking at it.
This is called the int Enum pattern in the official description of Java Enums. The documentation also lists some problems with this, starting with type safety, which we're not that concerned with in PHP anyway. A more relevant problem is the fact that when you print the value, you just get the number.
But I don't see why you shouldn't use strings for the values: class Role const REGULAR = 'REGULAR'; const WEBMASTER = 'WEBMASTER'; const ADMINISTRATOR = 'ADMINISTRATOR'; ...
One PHP-specific problem I didn't mention in the book is the problem that happens with long class names. Since we still don't officially have namespaces in PHP, we will easily end up with nauseatingly long constant names, like this:
It's quite depressing to have to do that a lot. I've tried putting constants in their own class with a shorter name, but I didn't like it much. One thing I tried recently was creating instance methods to return the constant value:
class MyProject_Authorization_RBAC_Role... public function REGULAR { return self::REGULAR } public function WEBMASTER { return self::WEBMASTER } public function ADMINISTRATOR { return self::ADMINISTRATOR }Now we can create an instance with a short name and get the values from that:
$roles = new MyProject_Authorization_RBAC_Role; if ($role == $roles->ADMINISTRATOR())...
All of this just to get shorter names? I little desperate perhaps. So yes, I would like Enums in PHP.