Search code examples
namingconvention

Counter file placement and naming convention


Ok this one might be stupid, but i'm losing too much time overthinking a solution.

I have a web app with 2 differents kind of payment modules. These modules need (each) a counter file, incremented each time someone want to pay, and locked while incrementing to make sure the payment get a unique payment reference.

The files were placed inside the main directory (public_html) and have been overriden by a bad versionning move.

So I want to move them outside of public_html, where I already placed the main config file. But having these critical file placed at the root of my ftp sounds stupind and dangerous. So I'll create a directory to place them.

This is a lot of text just to ask this :

How would you call this directory ?


Solution

  • IMO, your question has not related especially with PHP, it's a common issue. You can use of one of standard directories to share data between the applications.

    /var

    From the Filesystem Hierarchy Standard (FHS):

    /var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files. (read more)

    Some options:

    • You can store your file directly in the /var.
    • Also /var/tmp can hold temporary files for a longer time and doesn't clean it after reboot (depends on your system).
    • Or you can create a custom subdirectory in the /var/opt with name that relevant to your applications.