How is this not just a slower .htaccess implementation with OOP boilerplate? The instructions even mention editing .htaccess, so it's not like this is necessarily intended for people who don't have control of it.<p>RewriteRule ^foo/([0-9]+)/bar /foo/bar.php?x=$1 [L,NC,QSA]<p>Done.<p>These things come across as monkey-see-monkey-do. Other frameworks in other languages have routers, therefore they must also make sense in PHP.
Well done! This has a really clean interface, I wish I'd come across it when looking for a simple router a few weeks ago. A lot of the other ones lean heavily towards a style associated with their related framework, or are too esoteric/basic.<p>There are a few things I would have to add before I would use it however, and I hope they make it in some day:<p>1) You should add a whitelist for the HTTP request method names, i.e only allow calls to get(), post(), not some_suspicious_call_from_bad_user(). People will often put non HTTP methods in their views (view as in django sense) and you don't want them to be able to be called by a malicious user.<p>2) You should make it easy for the developer to configure their own xhr headers.<p>3) Nitpick: You should probably use 405 (Method Not Allowed) instead of 404 for when a method handler isn't found.<p>Maybe I'll use it in this project, in which case you may have a few pull requests headed your way!
Related: A similar project (a simple php router) called Klein exists (<a href="https://github.com/chriso/klein.php" rel="nofollow">https://github.com/chriso/klein.php</a>) which is really great. Does anyone have experience with both and can explain which is better?
Looks similar to Fat Free Framework for PHP, which I've been using for a few months. <a href="http://bcosca.github.com/fatfree/" rel="nofollow">http://bcosca.github.com/fatfree/</a>
Like everybody else, I wrote my own router which somehow began to grow and became a so-called microframework: <a href="http://azuki.desfrenes.com/" rel="nofollow">http://azuki.desfrenes.com/</a><p>This is probably what I would use for PHP, but obviously other languages have better solutions like ruby/sinatra, python/flask etc.
It's an interesting approach. I use SlimPHP, which approaches the RESTful API problem as a DSL, much like Sinatra. Slim has a few nice features, and my new preferred PHP stack is Slim Framework + Zend Framework as a library.
How can I bypass images or specific files using ToroPhp? I usually add this lines at my <i>.htaccess</i>:<p><pre><code> RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d</code></pre>
I used Moor for several projects and works like charms and it's very easy to use ( <a href="https://github.com/jeffturcotte/moor" rel="nofollow">https://github.com/jeffturcotte/moor</a> )
This illustrates exactly why PHP projects often become such an unmaintainable mess and security hole. This looks like an example collection of PHP worst practices.<p>I mean, what could possibly go wrong with untestable code and unfiltered input...?
Is this a parody of how not to do things? I was prepared to take it on face value of being rather misguided, but thinking about it... It's a glorified mess of goto statements and objects being misused.<p>I confess that I stopped digging further after I saw files being included in methods, absolutely one of the biggest sins in PHP:<p><a href="https://github.com/anandkunal/ToroPHP/blob/master/examples/blog/handlers/article_handler.php" rel="nofollow">https://github.com/anandkunal/ToroPHP/blob/master/examples/b...</a><p><a href="https://github.com/anandkunal/ToroPHP/blob/master/examples/blog/handlers/articles_handler.php" rel="nofollow">https://github.com/anandkunal/ToroPHP/blob/master/examples/b...</a>