3 ms·
Aside from this being "Sinatra clone" #100, I think most people do not understand that Sinatra is about much more than its query and before/after-filter DSL: It
by Argorak 16y ago
Aside from this being "Sinatra clone" #100, I think most people do not understand that Sinatra is about much more than its query and before/after-filter DSL: Its about its plugin API, its great integration into Rack (which PHP doesn't have, middleware solutions or not), its ability to host multiple apps in one process and its large and well-written documentation.
It is easy to implement the query API in any language that supports anonymous functions, but that doesn't make it Sinatra.
This one is not even a good example of a clone: its really bare, only implements the minimal set to "look like sinatra". It doesn't even have a good request or response object.
- dhotson 16y agoHeh, it's funny you should mention that.. I had a go at a Sinatra + Rack style framework in PHP a little while ago. Check it out: http://github.com/dhotson/kelpie http://github.com/dhotson/kelpie http://github.com/dhotson/kelpie/blob/master/demoapp.php http://github.com/dhotson/kelpie/blob/master/demoapp.php It's got its own Rack style web server built in ... kinda crazy huh? ;-)
- Argorak 16y agoIt looks nice and much cleaner :). Is there a reason for the use of doc comments? My problem in the PHP world is: you have your Rack-style server. Another project has a different style. In Ruby, every framework nowadays is on Rack.
- dhotson 16y agoNo particular reason it uses docblocks.. it's just what I thought looked decent at the time. I'm usually not a fan of comments as code, but in this case it's kinda neat.. :-) It's a real challenge to make nice looking mini languages in PHP. At least Ruby gives you a bit more rope to make clever little languages. /envy But yeah, I really wish PHP had a web server interface like Rack that was more widely accepted. The two that look the most promising are: http://mongrel2.org http://mongrel2.org http://github.com/indeyets/appserver-in-php http://github.com/indeyets/appserver-in-php Also, the downside of implementing your own web server is that basically zero existing PHP code will work with it. It's because you have to re-implement all the usual superglobal stuff $_GET $_POST $_SESSION etc.. .. I consider that a plus. ;-)
- Argorak 16y agoWell, Mongrel2 sort of acts like a common web interface, but only if the other side adopts it. It really depends, frameworks like Agavi do not use $_GET etc. and explicitly disallow their use.
- luciferous 16y agoCan I get some thoughts on http://github.com/luciferous/pip http://github.com/luciferous/pip? It's an interface and a web server (and framework). Its a ways to becoming near a standard. I think it "fights" PHP style in its current state.
- dhotson 16y agoLooking pretty good. Nice one. :-) I can't claim much credit for the design of Kelpie, it's mostly a direct port of Ruby's Thin web server. I guess there's a couple of notes I'd make: - I'd recommend using the mongrel http parser rather than implementing your own. I wrote a PHP extension for it - http://github.com/dhotson/httpparser-php http://github.com/dhotson/httpparser-php Also, some cosmetic stuff (feel free to ignore): - I prefer camelCase for methods - public/private access control on methods - PHP namespaces look and act weird to me so I don't use them - I prefer using underscores in names and a classloader to avoid require statements
- luciferous 16y agoThanks for that! I was looking at your PHP extension a few months ago, but didn't come to a decision on integrating something that users would need to install in addition to the standard PHP package. I'm definitely thinking a lot about the cosmetics of the code, especially since looks different from PEAR etc...
- dhotson 16y agoAh yep, I guess it'd be good to have a pure PHP fallback for HTTP parsing. Also, I've pretty much developed my own PHP style. I don't follow PEAR conventions.. I go with what looks clearest to me. So obviously you'll want to take my advice with a grain of salt.