this post was submitted on 16 Jun 2023
76 points (100.0% liked)

Programming

13368 readers
2 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

I don't know if it's due to over-exposure to programming memes but I certainly believed that no one was starting new PHP projects in 2023 (or 2020, or 2018, or 2012...). I was under the impression we only still discussed it at all because WordPress is still around.

Would a PHP evangelist like to disabuse me of my notions and make an argument for using PHP for projects such as Kbin in this day and age?

you are viewing a single comment's thread
view the rest of the comments
[–] l3mming@lemmy.fmhy.ml 6 points 1 year ago* (last edited 1 year ago) (1 children)

It is that easy in php:

$jsonConfig = file_get_contents('config.json');
$config = json_decode($jsonConfig);

  

[–] tias@discuss.tchncs.de 2 points 1 year ago (1 children)

Well in that case, it's just bad coding.

I guess there's a tendency for interpreted languages to attract more bad coders because trial & error is easier and you can get started in fewer steps. Also, fewer confusing compiler errors to deal with.

[–] pjb@lemmy.spacestation14.com 4 points 1 year ago

To be honest, the "configuration is an executed .php file" system does make some amount of sense in the context of PHP. When your app has to re-run everything to serve a web request, having to re-load the config (especially if it's YAML, though JSON is less bad) is expensive. Re-running the PHP code, on the other hand, can be cached way better, in theory.

Of course, this is still all PHP's fault in the end: the core problem here is that you need to re-run everything to serve a web request, without ability to pre-load state like configuration.