Search code examples
phpserializationarchitecturedata-access-layer

Is PHP serialization a good choice for storing data of a small website modified by a single person


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?


Solution

  • 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.