Web application directory structure

During my experience as a web developer, I always found that a well organized directory structure is the base of a good web application. Through the years I have frequently modified the structure, because I felt some things just weren’t right.

Below I will list the directory structure which currently works pretty well for my needs. I will not go into too much details, as I think most things are self explanatory.

project

  • app
    • controllers
      • newsController.php
    • etc
      • schemas
      • config.ini
    • jobs
    • models
      • newsModel.php
    • plugins
    • templates
      • news
        • __form.html
        • add.html
        • edit.html
        • list.html
    • application.php
  • libs
    • PEAR
    • Smarty
    • Zend
  • public_html
    • css
    • images
    • js
    • .htaccess
    • bootstrap.php
  • tests
    • NewsTest.php
  • tmp
    • cache
    • templates_c

The controllers/ directory

The controllers/ directory contains all the controllers for the application.

The etc/ directory

Configuration and database schema files will go here.

The jobs/ directory

Cron jobs, database schema migration scripts or import scripts to be written. These are run using the PHP CLI executable and are stored here.

The models/ directory

Holds model classes, some of which are derived from database abstraction layer, such as PEAR’s DB_DataObject.

The plugins/ directory

Since I am using Smarty, I will put my custom plugins here.

The templates/ directory

This contains a sub-folder for each controller (named after the controller) and also some layout template files. Within each sub-directory there is a template file named after the action and possibly some additional helper templates which I prefix with 2 underscores.

The application.php file

This file will contain all the different stages of the application, such as loading configuration data, setting up a database connection, etc.

The lib/ Directory

Any third party library is stored in here. Most of the time, this directory is maintained by svn:externals.

The public_html/ Directory

This one is pretty obvious I think …

The tests/ directory

Unit tests (mostly for models) will go here.

The tmp/ directory

This is the base folder for all sort of files that can be deleted! Anything transient is stored here.

Questions? Suggestions? Shoot!

PHP Bootcamp

On June 2nd, the first PHP Bootcamp will be held by Dutch Open Projects. The idea behind this bootcamp is a day with sessions about PHP-related subjects, and a panel-discussion.

Stefan Koopmanschap was kind enough to ask me if I would like to present a paper about the Zend Framework, but since I am not very experienced with presenting papers, I have rejected the offer, and suggested to have Thomas Weidner do the talk. Thomas accepted the offer, and it seems like he will be doing the talk now!

Unfortunately I am not completely certain if I will go or not … but hopefully I will be able to make it there!

Minimal Payment, or oopz was it Minimal Design?

Everybody knows that I am a PHP developer, but I also do some frontend work now and then. A few weeks ago I got in contact with a guy named Yann Bettremieux. Yann’s running Minimal Design, and he asked me to do some HTML and CSS work for him.

After I had been given the PSD files, I concluded that this job would take me approximately 10 hours to finish:

- 2 hours: photoshop slicing
- 3 hours: xhtml “coding”
- 3 hours: css “coding” and finetuning
- 2 hours: risk marge

Yann seemed to be fine with this estimate, and paid me 50% up front, so I could get started on the project as soon as possible. The project had to be deliverd on 21 May. After completion of the job (Saturday 19 May), I sent Yann an invoice for the remaining 50%. Turns out he wants the HTML and CSS files before he will complete the payment. Ok, trusting in good faith I sent Yann the completed HTML and CSS.

Yann then stated that the completed work is not to his satisfaction, so I offerd him an additional 2 hours of work at no charge beyond our original agreement (50% to start, 50% upon delivery), in order to meet the shortcomings that he had identified. I asked Yann to simply provide me with a prioritized list detailing where the problem areas are, and told him that I would address them with the available additional time. Yann did not want this, nor did he want to pay the remaining 50%. The reason? It was not “pixel perfect”.

I also admitted to Yann that I had lost some confidence in his willingness to fully honor our agreement by refusing to pay the second 50% of the project budget. This is largely because he indicated the possibility after I had provided access to the project deliverables, the HTML and CSS.

I trusted in good faith that he would remain willing to honor his part of our agreement, providing me with the reasons why the project remains incomplete, so that I may service the requests at no additional cost to you beyond the original agreed upon amounts.

Yann very friendly responded to me:
“Our agreement was that you’d DELIVER YESTERDAY. You didn’t. Agreement is OFF. You owe me $xxx Please pay me back ASAP. “

Like I already said before, I delivered on Saturday 19 May, which was 2 days early. The files were not good enough for Yann, because they were not “pixel perfect”. Yann refused to tell me what was wrong with my work, and did not give me the opportunity to fix the “errors”. Instead he’s asking for a refund? Arguing with Yann Bettremieux obviously makes no sense, so I’m not going to waste another day on him.

I have made a screenshot with original PSD, and overlayed it with my HTML (transparent) to demonstrate how close the result was:

Upon request from Yann (see comment below) I have removed the screenshot. We did not sign a non-disclosure agreement (which means that I am still the legal copyright owner of the HTML/CSS), but whatever. If you would like to see the result, please contact me.

Are you interested in losing your money? Then Minimal Design LLC (Yann Bettremieux) is the place to go!

Update: I received another nice letter from Yann:

“You’re trying to hide behind the “pixel perfect” excuse but you know as well as I that what you sent me was not even within the 15 PIXEL ballpark… And that’s not all, it was also missing elements like the scrollbar place holder (never asked for JS, just a HTML place holder, for which I even sent you a sample of code ’cause I knew it was tricky), the decorative little squares, ETC ETC… the list never ends… All that has NOTHING to do with pixel perfection, it’s just SLOPPY.

No one would accept such sloppy work. You think I had fun redoing everything in an 8 hour last minute crunch yesterday? If your work was usable, what reason could I possibly have to redo the whole thing? Just think about it… I recommend you get over yourself and show what you did to colleagues w/ the original jpgs for comparison and see what they tell you. You might learn something…

I could forgive the fact that you got me in trouble because you’re clearly unexperienced and I was going to just let it slide… But since you’re talking about legal actions, you better send me my money back ASAP or have a good lawyer in your family ’cause I do and I’m going to get my money back from you. Your “pixel perfect” excuse is never going to work, just so you know…

Don’t bother answering, just send me my money. You won’t hear from me anymore, beside through my lawyer.”