3 ms·
FWIW at Etsy I built and subsequently helped completely dismantle a minimal PHP routing framework. We just used .htaccess and php files. PHP/Apache affords you
by mcfunley 12y ago
FWIW at Etsy I built and subsequently helped completely dismantle a minimal PHP routing framework. We just used .htaccess and php files.
PHP/Apache affords you a fast, simple alternative, and what you gain with a framework (route lookup for an object) just isn't compelling enough IMO to justify the added overhead and complexity.
I think the endless proliferation of PHP microrouters (including mine, RIP) is people porting Django and Rails features to PHP without applying critical thinking first. (Myself included.)
- 127001brewer 12y agoHow complicated were the Etsy routes? And were the added overhead and complexity? And I know it is a pain to restart Apache each time there's a change to the configuration file, but does anyone know the time differences between a PHP router and Apache rewrites?
- icedchai 12y agoPut it in .htaccess. No restarts needed.
- 127001brewer 12y agoThat's correct - I was thinking of using an Apache VirtualHost file. (Isn't using the .htaccess file slower(?) than using the VirtualHost file?)
- mcfunley 12y agoBasically just "/listing/<a number>/<some ignored text> goes to listing.php", multiplied by a thousand pages or so. There's overhead associated with doing the bookkeeping necessary to compute the route lookups. In practice, it's not that awful to just write a function like "get_url($listing_id)" by hand, and debugging this later is much more straightforward. We didn't need to restart httpd (in development at least) to add to .htaccess. For production deploys maybe we were configured to do this, but that's hidden from development.
- yowmamasita 12y agothen I think what would be best here is a command line tool to manage your routes on .htaccess or nginx configs.