Andrei Herford
Andrei Herford

Reputation: 18765

Symfony 2: How and where to store runtime settings file

I am working on a Symfony 2 WebApp that uses the PayPal Rest API to create and accept PayPal payments.

To be able to redirect each user to a PayPal page in his language, one has to create an Experience Profile for each language/locale.

Each Experience Profile has to be created only once. For example once a profile for US locale has been create, this profile can be re-used for every customer using the same locale:

  1. Customer enters his address and contry XY on my page
  2. My page checks if profile for XY locale exists
  3. Create new profile for XY locale and store it OR re-use existing one

Each profile has a unique ID. Thus I am looking for a method to store Locale/ID pairs. A simple solution would be a JSON file. But where to store this file within the Symfony structure?

Profiles are created on the fly when ever a user from a new country places a payment. Thus this data is created during runtime and because of this it does not belong into the standard config dirs of Symfony I think. I do not even know if these folders should accessible/writeable by my code.

So: What is the right place to store such a file.

EDIT: As @JimL pointed out in the comments it would of course be possible to store the data in the DB. However the Payment Bundle I am working on, should be used in different projects and thus be as separated from the rest of the project as possible.

The goal here is, to store the data in a file, not in the DB. Of course the DB is much more efficient but in this special case a simple file will be sufficient.

The question is: Where to store this file? First idea is to use /MyBundle/Resources/config since this dir holds all other config files. But is this the right place for files that change at run time as well?

Upvotes: 1

Views: 436

Answers (1)

John Smith
John Smith

Reputation: 1110

Standard Symfony directory structure for 3.x is:

app/ The application configuration, templates and translations.

bin/ Executable files (e.g. bin/console).

src/ The project's PHP code.

tests/ Automatic tests (e.g. Unit tests). Standard Directory Structure is:

var/ Generated files (cache, logs, etc.).

vendor/ The third-party dependencies.

web/ The web root directory.

You can put it in the standard var directory under your custom directory. Remember about permissions.

More general info on var directory: http://www.linfo.org/var.html

Upvotes: 2

Related Questions