[thelist] PHP Organization

Boris Mann boris at bmannconsulting.com
Wed Jul 10 14:00:01 CDT 2002


The one problem I see with your proposed structure is that I find it
very confusing to have multiple files with the same name. So, while
editing, I would potentially have 3 files all called index.php open at
the same time...

I would make the organization flat. You could call your "main" file
index.php, but the products one would be 'products.php' for the main
file. All other related files could be named '<something>_products.php'
or, as you've done, name them for their function.

Makes it easy to do includes as well, because you don't have to start
mucking with relative ("../../../something.php") or absolute
("/home/site23/fst/var/www/html/coolapp/products/something.php") paths.

My 2cents,

--
Boris Mann
http://www.bmannconsulting.com

On Wednesday, July 10, 2002, at 02:43 PM, Beau Hartshorne wrote:

> Instead, I'd like to keep smaller chunks of code seperated in different
> .php files, and use one "brain" .php file per major section (product
> catalogue, contact, etc) to figure out which of the smaller .php files
> to include. I think a good way to organize this would be to keep
> separate directories for each section, and keep all of the .php files
> that are unique to that section in their directory. The "brain" .php
> file would be the index.php file inside whatever directory. So, the
> directory structure would look something like this:
>
> /index.php
> /contact/index.php
> /contact/print_contact-form.php
> /contact/check_contact-form.php
> /contact/update_contact-database.php
> /products/index.php
> /products/show_catalogue.php
> /products/show_item.php
>
> etc...
>
> There will probably be a few things that the entire app would need
> access to. They could be kept in a /global directory.
>
> Another advantage is that you could code links like this:
> <http://www.foo.com/bar/> instead of: <http://www.foo.com/bar.php>.
>
> Does anyone see any potential problems with this structure? Can anyone
> make any suggestions to make it better?
>
> Thank you,
>
> Beau




More information about the thelist mailing list