News for hackers. Stuff that matters.
Re:PHP in 2022 by dncornholio on Tuesday January 11, 2022 @09:29AM (#29891785)
Storing stuff in a json file sounds horrible to me. Why would you want that?
Re:PHP in 2022 by Spivak on Tuesday January 11, 2022 @10:21AM (#29892489)
Because your data is teeny tiny, not performance critical, and `json.load` and `json.dump` is easy and usually less brittle then you're language's marshalling library.
Re:PHP in 2022 by dncornholio on Tuesday January 11, 2022 @10:52AM (#29892962)
Why save 10 minutes on setting up a proper database? Data is never teeny tiny, data is never not performance critical :) These decisions only bite you in the ass.
Re:PHP in 2022 by hmottestad on Tuesday January 11, 2022 @01:42PM (#29895765)
All my side projects have teeny tiny amounts of data. JSON file in the order of KB. Performance is great.

I have one project with a dozen users that handles around 50 reads per second and maybe 30 writes per day, no issues at all. Setting up a DB for that would just bite the next dev in the behind since it would need a lot more maintenance then an apache server with php.

Re:PHP in 2022 by lghh on Tuesday January 11, 2022 @11:34AM (#29893713)
Setting up a database takes way longer than 10 minutes. Data can be teeny tiny. Data can not be performance critical. You literally know nothing about the commenter’s application.
Re:PHP in 2022 by xigoi on Tuesday January 11, 2022 @05:53PM (#29899546)
With SQLite, you can have a simple database set up in a minute.
Re:PHP in 2022 by Spivak on Tuesday January 11, 2022 @01:07PM (#29895215)
"I just want to serve five kilobytes of data."
Re:PHP in 2022 by paul_f on Tuesday January 11, 2022 @11:33AM (#29893690)
PHP supports complex data structures using associative arrays which map to the application requirements. Which can be easily saved in JSON. A SQL database with rows and fields does not always work well with these data structures. Often, as long as the data size is manageable, a json saved in a mediumtext field in MySQL works just fine.