views:

45

answers:

4

Hi,

I'm planning a PHP website architecture. It will be a small website with few visitors and small set of data. The data is modified exclusively by a single user (administrator).

To make things easier, I don't want to bother with a real database or XML data. I think about storing all data through PHP serialization into several files. So for example if there are several categories, I will store an array containing Category class instances for each category.

Are there any pitfalls using PHP serialization in those circumstances?

+1  A: 

The pitfalls come when with maintenance and adding functionality.

it is a very good way to learn but you will appreciate databases more after the lessons.

Yehonatan
It's not about appreciating databases or not. I appreciate them a lot, but I use mostly Microsoft SQL, and it will not be available on the deployment server. I can always use Sqlite, but the fact is that for a website as small, I think it's just doesn't matter what data support is chosen, and I don't want to add a real data-access-layer just for adding it.
MainMa
+2  A: 

Use databases -- it is not that difficult and any extra time spent will be well learnt with database use.

The pitfalls I see are as Yehonatan mentioned:

1. Maintenance and adding functionality.
2. No easy way to query or look at data.
3. Very insecure -- take a look at "hackthissite.org". A lot of the beginning examples have to do with hacking where someone put the data hard coded in files.
4. Serialization will work for one array, meaning one table. If you have to do anything like have parent categories that have to match up to other data, not going to work so well.

Kerry
+1 for nice explanation, I truly agree with the Point "4"
Chetan sharma
A: 

I would say use a small database like sqlite if you don't want to go through setting up a full db server. However I will also say that serializing an array and storing that in a text file is pretty dang fast. I've had to serialize an array with a few thousand records (a dump from a database) and used that as a temp database when our DB server was being rebuilt for a few days.

Jonathan Kuhn
A: 

Why not use a standard CMS, like drupal or joomla ?

They are easy to install, and do most of the work for you, even for a single user site.

uvgroovy
Because the website is not about sharing *some random data*, but rather about sharing *very structured data* (precise objects with precise properties) and let the users interact with it. IMO, a CMS is not a solution here.
MainMa
You'd be surprised to the flexibility of drupal cMS.
uvgroovy