Archive for the ‘Development’ Category.
28th March 2008, 01:46 pm
In my previous article (Microsoft Access and PHP), I discussed getting mdbtools setup and dynamically interacting with a instance of mdb-sql. Well it turns out somewhere in the pipeline (probably mdb-tools), we're either not getting an EOF or reading an EOF right and as such I can read lines from the program's STDOUT stream, but as soon as I hit the end of the output my script hangs indefinitely waiting for something and all my attempts at detecting an EOF failed. Sorry to disappoint.
On lighter news, my coworker got the greatest error ever:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
Turns out according to these guys it's Hebrew and refers to the double colon (::) operator.
Right...
24th March 2008, 11:32 pm
Microsoft products can really be a big wrench in the finely oiled machine that is your development environment. While Microsoft does offer some excellent products and development tools, when you work from an open source context, these great tools become great hazards and headaches.
Case in point, access databases. Take as a recent example, a client that gets its data from a third party. That data comes in a Access (.mdb) format, probably convenient for the producing company as well as the assumption that chances are very likely that the person receiving the data will be able to read it (due to the widespread availability of Microsoft Office).
Importing said .mdb in PHP is not so nice or convenient, that is if you aren't running your server on Windows (which chances are you aren't). In Windows you merely need to either create an ADO object (or use ADODB), or use COM to communicate with a local install of Microsoft Office to trigger an export. In Linux, neither of those choices are even available. However we thankfully have some good command line utilities, for example: MDB Tools. (Tip: Check out a copy from CVS if 0.5 is segfaulting on your database)
In addition to some unixODBC drivers, it provides some very nice command line utilities like mdb-tables (which prints the tables in a .mdb file), mdb-schema (which prints the schema for all or a specific table), mdb-export (which produces a CSV output of a specific table in the .mdb), and mdb-sql (which provides a subset of SQL interface to the .mdb file). All of these tools come together to form a very nice tool set to import a .mdb file.
Fun things however, as I was working on my import script (I was just using simple exec() commands and getting full output and parsing from there), I decided to play around with stream programming and provide an interface to mdb-sql using proc_open() to make the import less memory intensive. I ran into some snags using fgets() on the STDIN stream and when I solve those I'll post my code and a tutorial.
14th March 2008, 12:34 am
I was helping a coworker the other day with some object oriented design issues in PHP and thought it would be great to share with the general PHP community as the general PHP community seems to lack in good OOP skills.
The task, which will be detailed later when we release it, boiled down to having a collection of files we needed to perform an operation on. Sometimes the entire collection, sometimes just a subgroup. Currently the system will only support 1 kind of file however in the very near future a new file will be added. My coworker tackled it well but a few problems that I helped him out with. Namely he made a few common mistakes in the design that most PHP developers make, namely being inconsistent with naming/etc. and not utilizing Interfaces and argument type-hinting to enforce good design, as well as putting logic in the wrong classes.
One of the few pitfalls that did happened was placing the render() function in the collection class. While this would not be a problem for a single type, when extending the system to handle n node types we come across unnecessary complexity issues in adding to the render() function, as well as making it nigh-impossible to keep the original includes intact (so as to make upgrades work without the hassle of merging code).
Continue reading ‘OO Design and PHP’ »
15th February 2008, 01:29 am
I've started to amass a large amount of feeds in my reader and I thought I'd share a few with you:
PHPDeveloper.org (feed)
Great aggregation of blog posts and updates in the PHP world.
Zend Developer Zone (feed)
Zend's place for all things PHP related
SitePoint.com (blogs) (articles)
The infamous SitePoint. Not entirely PHP, but excellent web related articles and a good way to keep loose tabs on the other web spheres (ASP.NET and RoR in particular)
Particletree (feed)
Doesn't update very often, but each article is a gem (in terms of solving a programming problem).
Chris Shiflett (feed)
THE PHP and Web Application Security guy.
Joel on Software (feed)
A classic, not really PHP oriented.
And finally, definitely not PHP focused, but a very good blog to read if you do any MySQL work (if you are a PHP person, chances are this includes you)
MySQL Performance Blog (feed)
Great collection of articles and talks on optimizing MySQL, either at the server or query level, and more...
While this isn't all of the feeds I have on programming related topics, some of them are new adds and I want to give it some time before I share the links.
2nd February 2008, 05:03 pm
My (Our, Chris included) slides have been featured on the front page of SlideShare's website!
Small time success yes, but success none the less. Take that Ed Schipul, my slides are right next to yours! (Btw Ed, I still think your presentation you gave to refreshBCS was good, but I still disagree with your thoughts on work days and work weeks).

2nd February 2008, 01:47 am
Unfortunately, Plesk does (and according to atomicturtle will continue to) hate on developers by enabling open_basedir by default and not give any way to change such behavior.
A work around is possible, overriding the setting in a vhost.conf file (httpd.include files are not so good because Plesk rewrites them every time a change is made to a domain's settings, or whenever Plesk feels like it). However, adding the line php_admin_value open_basedir none is completely ineffective (as I would assume the vhost.conf is being included before offending open_basedir changes are made?).
However I found that doing this (those familiar with Plesk's httpd.include will recognize this block):
<Directory /path/to/domain/httpdocs>
<IfModule sapi_apache2.c>
php_admin_value open_basedir none
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir none
</IfModule>
</Directory>
Guarantees that open_basedir will plague you no more.
Some may ask why I want open_basedir enabled, it's leaving me open to vulnerabilities! Some applications have a control panel on a separate sub domain and require the ability to write files to it's parent domain, something Plesk beats down with an ugly stick, as well as some applications requiring access to the system wide PEAR libraries, something open_basedir ironicaly beats down as well (despite the system wide PEAR libraries being included in the include_path directive).
Later I'll be digging through Plesk's ability to trigger commands on updates and domain creations to automate this vhost.conf setting (namely grabbing that path to the httpdocs folder that is so critical and time consuming).
EDIT: To apply the changes, follow markus' example:
I just have my setting in the vhost.conf, and it works just fine. Just remember to update Plesks settings manually afterwards, with /usr/local/psa/admin/sbin/websrvmng -u –vhost-name=example.com (it doesn’t read directly from the vhost.conf).
31st January 2008, 11:18 am
So I'm setting up my windows PC at home (hooray compsci classes being an all Microsoft setup, requiring Visual Studio 2005), downloading the MySQL GUI tools, launching them to test when I notice that MySQL Workbench went through a HUGE overhaul. When I say huge I mean "It Actually Works Now And Looks Completely Different" huge.
Which is funny 'cause last time I downloaded the work bench it was horrendously broken alpha software. Version 1.1. Now we are at 5.0 Beta? About 3 months later!?

Crazy. I guess I need to pay more attention?
Though the real question is right now, how does it stack up in a real world situation? Well I had to finish up the database design for some client work so I decided to try working it in MySQL Workbench (rather than my usual staple, the sadly discontinued DBDesigner).
Continue reading ‘MySQL Workbench 5 Beta (Or: WTF?)’ »
29th January 2008, 12:04 pm
Slowly but surely my framework is coming off the ground. I decided to adopt a singleton design pattern for my Cache, Template, and possibly any other engines I might have. Originally my design started as a factory, however it is now somewhat of a hybrid as there is a ::load() function that loads arbitrary classes into our singleton (rather than an instance of the same class like a proper singleton).
I wanted the system pluggable so the developer was not beholden to any particular engine, but I also needed to guarantee access to the Cache and Template objects to the models without having to either add to the $GLOBALS[] array or add to a controller's attribute (and call like $controller->cache->...).
So I adopted a singleton design pattern, because (a) one only needs 1 cache or template object and (b) it just looks plain nice.
Continue reading ‘Singleton-Factory Hybrids FTW’ »
26th January 2008, 10:00 am
These are the powerpoint slides from the presentation I gave at Bar Camp Texas, 2008. The slides are currently out of date, I'll publish the fixed ones later.
The slides are licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.
PHP MVC Slides (Powerpoint 2007)
PHP MVC Slides (PDF)
24th January 2008, 05:55 pm
So, crazy me decided to give a talk at BarCamp Texas on MVC design in PHP.
With the prevalence of MVC frameworks becoming more and more ubiquitous in PHP development (CakePHP, Symfony, and the Zend frameworks), I wanted to make sure that (a) the non-developer types were introduced to such styles of PHP development, and (b) introduce those developers with little formal experience (very common in the PHP world) to what MVC actually is and that MVC does NOT require large expansive libraries.
I could do my presentation showing out to setup a basic application with an existing application, however I don't feel that would be beneficial. The idea is knowledge portability, and I feel a good understanding of the basics of OO design will be transferable to any other frameworks, since all the aforementioned frameworks have excellent "getting started" tutorials.
When I finalize my slides, I will post them here for people to take a look at, possibly to berate my retardedness.