First: I'm not sure if this belongs in General Discussion or PHP Code so... sorry if this is in the wrong place.
I would like some suggestions for small to medium sized projects that could fairly easily be used in other places. I'm new to php, so I would like the projects I start on to be gradually building in complexity. Here are the two projects I've already started and (mostly) finished:
1. Build a login class - Finished several months ago, this was my first attempt at php security. It works, but is very crude, and I rewrote it from the ground up in my second project. Features include: using javascript to validate input before processing, php validation for those without js enabled, and sha256 encryption (using feyd's class).
2. Build a backend for a simple website - Mostly finished this last week. Applicable towards a fairly limited range of database driven websites (not as flexible as I was hoping for). Features include: remove/create a page/category, change menu order, edit page content (still needs a validator), change password, create new administrator with x, y, or z permissions, and remove administrator.
My next project will probably be one of the following build a chat room (unless you guys have better suggestions/ideas).
From these two projects, I know that I want to (in no particular order):
A. Eliminate duplicate code - I need to make my functions smaller, and more generic.
B. Understand classes better - My classes are _very_ basic. I know I could do a lot more with them.
C. Learn more complicated mysql queries - Currently my knowledge consists of SELECT, FROM, and WHERE (basically).
D. Learn when and how to use files - When _is_ using a file better than using a database?
E. Get better at form validation - I'm getting there... I just need practice.
So. I'm looking for suggestions for things that I can code that will help me with any, or all of those goals. In short:
What should I code next?
Where to next?
Moderator: General Moderators
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
A chat room would actually be a good project. It's reasonably small, requires some form of input/output management, depending on storage - database or xml, and may introduce a little Javascript (not as horrific as it sounds
). Input filtering is even important unless you want messages to XSS users to oblivion
.
I wrote a tutorial about a year ago in 7 parts for Zend Devzone which used the Zend Framework, but the basic code might be helpful.
http://devzone.zend.com/article/1581-Ajax-Chat-Tutorial
Note it was quite literally done in a few hours - there are lots of ways to improve it but it was deliberately kept simple to demonstrate some useful principles. It was subsequently updated (nobody likes a simple tutorial without making it more complicated so you can illustrate stuff on slides for 40 mins
) but I don't have a link handy - the original was likely easier to follow anyway since I followed each step in detail assuming no experienced knowledge.
On the file vs database issue. I sometimes use files for very temporary data whose size is small. Like in the chat app above I stored messages to an XML file which was truncated regularly (if ever someone wanted permanent logging a database could easily be substituted). The other thing with files is that it requires the file be locked for writing - only one PHP process can write to a file at a time. Mind you a database can have the exact same problem - something often overlooked in writing Session adapters for databases.
I wrote a tutorial about a year ago in 7 parts for Zend Devzone which used the Zend Framework, but the basic code might be helpful.
http://devzone.zend.com/article/1581-Ajax-Chat-Tutorial
Note it was quite literally done in a few hours - there are lots of ways to improve it but it was deliberately kept simple to demonstrate some useful principles. It was subsequently updated (nobody likes a simple tutorial without making it more complicated so you can illustrate stuff on slides for 40 mins
On the file vs database issue. I sometimes use files for very temporary data whose size is small. Like in the chat app above I stored messages to an XML file which was truncated regularly (if ever someone wanted permanent logging a database could easily be substituted). The other thing with files is that it requires the file be locked for writing - only one PHP process can write to a file at a time. Mind you a database can have the exact same problem - something often overlooked in writing Session adapters for databases.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
A shopping cart (if it hasn't already been mentioned).
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.