3 ms·
PHP, hear me out, each file is basically an independent hot swappable 'service'. I wish more languages/compilers/runtimes had a similar capability.
by trixie_ 5y ago
PHP, hear me out, each file is basically an independent hot swappable 'service'.
I wish more languages/compilers/runtimes had a similar capability.
- diordiderot 5y agoCould you explain this more??
- KronisLV 5y ago> PHP, hear me out, each file is basically an independent hot swappable 'service'. I think that what the OP is referring to is the fact that you can map URLs to PHP files pretty easily and therefore changing what an endpoint does can be as simple as just swapping out a single file for another one. However, that tends to fall apart with most modern frameworks, like Symfony, Laravel, Lumen and Slim, where you will typically invoke a main application file which deals with all of the bootstrapping first (reading configuration, DB connections, logging etc.) and then will hand off control over to a router, which will usually map to a controller of some sort, which may have the actual business/view logic spread over other referenced files, the way as other similar technologies like (Ruby on Rails) do it. Of course, that's not a bad thing, especially since it allows you to follow some of the RESTful conventions, like having path variables without doing rewrites at the web server level, such as /users/12345/photos versus /users/photos.php?id=12345 That said, the whole "mostly single file, maybe with a few common imports" approach can also work fine, as long as your endpoints are kept relatively small. I haven't seen it scale up to large projects that well, at least most of the time.
- diordiderot 5y agoThanks for the reply!