Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheFriendlyHacker's avatar

Where to store a lot of static data?

Short background: I am working with a client who organizes lectures/conferences for audiences. The site I am building will be responsible for displaying information about these conferences as well as selling tickets for them.

TL;DR

I have a lot of semi-static data that needs to be displayed on a site (I say "semi-static" because it does not dynamically change based on the state of the application, but rather, it is manually updated whenever a change is needed). The client does not want to use a database to store this data, so I am currently organizing it into JSON files, and retrieving it when the corresponding page is loaded. I'm on shared hosting, so I don't have access to many "special" things other than MySQL (so no Redis or Memecached or SQLite, etc). What recommendations do you have? Do you think I'm doing it right? Do you know of a better way?

I have the ticket-selling part well under control. However, I do have a few questions about best practices for storing/displaying mostly static data on a Laravel app.

I say "mostly" static because, while this data does not change very often, it is changed up to a couple of times per month.

Some examples of this data includes:

  • Lists of upcoming conferences (basically an HTML table with a name, location and purchase link for each conference)
  • Lists of companies who are sponsoring each conference
  • Basically everything else follows a similar structure: a predictable list of entities that will be displayed on the site.

I don't necessarily want to store this information in the database (mainly because the client requested that I not do so...for some reason). So right now, I've created some JSON files in my application that contain all of the "static" data that will appear throughout the site. I've separated different "entites" into different JSON files as well (for example, on a page that display information for a specific conference, I will have one JSON file containing a list of people who will be speaking at the conference, another for companies that have sponsored the conference, one containing a schedule, etc).

How would you go about storing data like this on a website? I know I could always "hard code" the data into my views...but I really don't want to do that. I prefer having all of the data be stored outside of the view (as does the other guy who is helping me work on this project). Additionally, the site is on a shared hosting account...so I won't be able to make use of anything too fancy, such as SQLite, redis, etc.

And recommendations?

0 likes
3 replies
silverxjohn's avatar

I'm not sure if I understand you correctly. Do you mean doing something like this:

<?php

class Conference
{
    public $name;
    public $location;
    public $purchaseUrl;
    // etc...
}

Then, as suggested above, create a rather simple php file

<?php

$conference1 = new Conference();
$conference1->name = 'The New World';
$conference1->location= 'Somewhere';
$conference1->purchaseUrl = 'somewebsite.com/purchase/254uyv18g9';
// etc...

// Then push them to $conferences array.
$conferences = [
    $conference1, $conference2, $conference3
]

Then, you can render the table like so:

<table>
<thead>
    <tr>
        <td>Name</td>
        <td>Location</td>
        <td>Purchase Link</td>
    </tr>
</thead>
<tbody>
@foreach ($conferences as $conference)
    <tr>
        <td>{{ $conference->name }}</td>
        <td>{{ $conference->location }}</td>
        <td><a href="{{ $conference->purchaseUrl }}">Buy Tickets Now</a></td>
    </tr>
@endforeach
</tbody>
</table>

The advantage of this over using your current implementation is that, all your codes are written in PHP!

EDIT: I forgot you need to import the file with $conferences array.

andonovn's avatar

@silverxjohn I really don't like the solution you are proposing as you are tightly coupling too many things. Also, what you point out as an advantage isn't that important to be honest. There are other benefits tho, all explained in the StackOverflow's url I provided above.

Please or to participate in this conversation.