Best Practice Load JSON?

I’d like to seed my database with content that’s currently encoded in JSON files. Is there a best practice for where to place such files? E.g.,

  • Create an “assets/data” folder?
  • Create a “src/data” folder?
  • Some other place?

I plan to load the file(s) with something like this …

$dataFileContent= @file_get_contents($pathToFile);

What’s the cleanest way to get the filesystem path to that folder (ie, so I can derive $pathToFile)?

Thanks in advance for any insight.

I’ll go with the locator for JSON files. src/ should be for PHP classes. As of UF 4.1, putting that file in assets:// or extra:// might be your best bet. If your sprinkle has the top priority one, you’ll end up with the file from your sprinkle. Otherwise, it simply means you can load another sprinkle on top to overwrite that file.

In UF 4.2, you’ll be able to define your own stream if you want to load your file from a custom URI (For example seeds://). Also note in 4.2 database seeding will change from Migration to the new seed command.

Thanks @Malou