views:

183

answers:

5
+1  Q: 

PHP Web-App Design

Am looking for a guide, or simple to understand method of designing a website.

I have a good idea of how to do various things in PHP anyways, basic knowledge of OOP, and functions and what not...

But I need some structure, to keep me on track and let me know what I should be doing.

Is there any websites, guides, or methods that can help me with this? Or maybe a application, client or web-app...

A: 

If what you mean is site structure, code layout, etc then this answer might help.

Gavin Gilmour
Not exactly code layout, but more project management which helps to design the application in a manner of speaking... For example certain bits of my application will not work without other underlining work done first... E.g. Database work, so that code work can be done...
Aran
+2  A: 

Honestly, what's worked the best for me has been a simple 'write it down before you do it' approach. If you just take the time to plan out how your service will function, you can save a lot of time later by not having to rewrite things!

It sounds like just writing down what you want to do, and how you can do it would help you a lot.

Fiarr
Yeah it would help, but was also wondering if there is a system, I can use where I could set it the stuff as tasks, so when I had completed that step I could just simply tick it off, and it would show I had to/could start a certain section now that had been done... I know this can be done on paper, but a system just seemed like a good way to manage such a thing.
Aran
+4  A: 

First you need to decide what your app is going to do and who is going to use it.

Next you can create use cases to start planning exactly what users will be doing. You can even make fancy little diagrams with stick figures and arrows.

Sequence diagrams and screen mockups will help you plan out how the system will work, and what pages you'll need.

You can also make a UML based class diagram which can really help you plan out what classes you'll need to make, including what methods and variables they'll need, as well as get you on track for designing the database to fit your website.

Doing these things may seem kind of boring or lame compared to jumping right in and writing code, but because it forces you to think ahead of time you can avoid a ton of pitfalls, even if you only do it half-assed.

From there you can actually make a serious TODO list, and order tasks by dependencies and priorities. I use text files. It's not the fanciest solution but it works for me.

Edit:

Expanding on my own process. Note that this is what I do while working by myself on my own projects.

Once I have the above sort of done, the next thing I'll do is actually write out the database tables, something like this:

USERS TABLE
===========
user_id (PK) unsigned int (10)
username varchar(30)
email_address varchar(30)
is_active bool
password varchar(41)
registration_date datatime
registration_ip varchar(20)
last_login_ip varchar(20)
last_login_date datetime

...etc. for all the tables. Then sit back and look at how the tables relate to each other, think of what might be missing, and normalize/denormalize until it makes sense for the app being built and especially the queries that will need to be written. Yes I do this in a text file.

I would strongly recommend, as others have, the MVC design pattern. It might not fit what you want to do, but it usually fits for most web apps and makes them so much easier to implement and maintain. The last thing you want is spaghetti code.

So if you are going to use MVC, it should be pretty clear what models you'll need to write (the most important part), as well as controller and view files.

So this is how I organize what I need to do:

TODO
- create database tables
- user registration
- authentication
...

SECURITY
- sessions in db table
- xss cleaning in form x
...

etc!

Every time I think of anything that I need to do it becomes a point. Obviously these points can easily expand out further. I try to order them by what I feel like working on next (because that's the easiest way to move forward) and by importance, or dependency from other tasks.

This might seem silly to some, but this is how I keep track of things. Hope it gives you some ideas.

mrinject
Do you have any examples of your text files? I think I may go down this route of using text files...
Aran
A: 

I agree with Gavin: You should learn about Model-View-Controller, as explained in the article Gavin cited.

It will give you a basic layout for your files and it will make you think about the database (when you plan the model).

One way to bring yourself to think more about your project is to find a partner an program together.

bjelli
I've been working with CodeIgniter and Kohana for a while, and they are a great time-saver. ( The latter is a branch of the former, and they're both MVC frameworks in PHP )Although they won't organize the site for you, but still a good help.
Petruza
+1  A: 

First of all I agree with what others have said about writing a few things down before you start -- even if it's just informal. This always helps you work through what the issues are and what pieces you'll need.

If you're somewhat new to some of the technologies you're using, one trick for me is to start on several less ambitious samples first. Don't be afraid to write something horrible as a first go around, because doing it badly once will teach you how to do it well a second time. Whatever you're doing, Hello World is your friend.

John Lockwood
I already do this.. Usually make something stupid.. So I can look back and laugh about what ever it does... Makes it more fun when making it and more fun when going over it again...
Aran