TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Toro - a php micro-router with great examples

34 pointsby jasonmooover 12 years ago

18 comments

mcfunleyover 12 years ago
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.
评论 #4424689 未加载
评论 #4424646 未加载
评论 #4424659 未加载
评论 #4424623 未加载
评论 #4424589 未加载
mmcnickleover 12 years ago
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!
评论 #4424533 未加载
citricsquidover 12 years ago
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?
评论 #4424833 未加载
评论 #4424941 未加载
solox3over 12 years ago
Reminds me of many things; as usual, the weakest part of this PHP router is the .htaccess file.
评论 #4424535 未加载
memnipsover 12 years ago
I've used Toro for about six months. It's excellent.
评论 #4424296 未加载
britoover 12 years ago
Simple, elegant solution to a typical problem where everybody else ends up building a broken wheel.
评论 #4424208 未加载
flyosityover 12 years ago
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>
desfrenesover 12 years ago
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.
jasonmooover 12 years ago
The toro mascot on the main site is pretty cool. <a href="http://toroweb.org/" rel="nofollow">http://toroweb.org/</a>
iguanaover 12 years ago
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.
devguttover 12 years ago
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>
评论 #4428245 未加载
jmtucuover 12 years ago
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> )
sjs382over 12 years ago
Similar to GluePHP: <a href="http://gluephp.com/documentation.html" rel="nofollow">http://gluephp.com/documentation.html</a>
rickmbover 12 years ago
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...?
评论 #4424371 未加载
评论 #4424507 未加载
评论 #4424569 未加载
评论 #4424721 未加载
jaequeryover 12 years ago
i wish zend framework's router was this easy
slurgfestover 12 years ago
Looks clean. Way to ship!
gteveldeover 12 years ago
i love it
mootothemaxover 12 years ago
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>
评论 #4424488 未加载
评论 #4424492 未加载
评论 #4424484 未加载
评论 #4424614 未加载