Re:Link: A fast and simple PHP Router
by 127001brewer on Thursday May 29, 2014 @01:30PM
(#7817419)
How 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?
Basically 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.
Put it in .htaccess. No restarts needed.
Re:Link: A fast and simple PHP Router
by 127001brewer on Thursday May 29, 2014 @01:38PM
(#7817476)
That's correct - I was thinking of using an Apache VirtualHost file. (Isn't using the .htaccess file slower(?) than using the VirtualHost file?)
It is slower, since .htaccess is parsed on every request. (However, it is probably faster than routing through PHP code.)
You can reload Apache without a restart (apache2/httpd graceful/reload depending on your distro).
Re:Link: A fast and simple PHP Router
by yowmamasita on Friday May 30, 2014 @07:16AM
(#7821147)
then I think what would be best here is a command line tool to manage your routes on .htaccess or nginx configs.
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.)