Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

just a few (stupid?) questions.. #152

Closed
gandaldf opened this issue Oct 31, 2013 · 4 comments
Closed

just a few (stupid?) questions.. #152

gandaldf opened this issue Oct 31, 2013 · 4 comments
Assignees

Comments

@gandaldf
Copy link

I would like to know if the redesign of the whole router (the 2.x version) has changed the speed of the router itself (the 2500+ requests per second) or if it's the same, I would like to know too if there's a way to require it inside my project without composer (I don't like very much the idea to load another class to autoload the router) and if the old version (before the redesign) is still maintained and where I can find it.

@Rican7
Copy link
Member

Rican7 commented Oct 31, 2013

No question is a stupid question. 😃

Although I'm sure that @chriso could speak more to the original design, it is my understanding that the original version of Klein was meant to be fast in terms of raw evaluation performance by optimizing the call-stack/graph. However, it was a trade off: The Klein library was a global driven (global functions and non-namespaced classes), difficult to test (there were no exchangeable units and it lacked DI), single file (making open-source maintenance more difficult) that made any customizations rather difficult and/or near impossible.

The true beauty of the original Klein library was its Sinatra-like routing style that allowed for expressive, loose routing with a callback structure. That has gone unchanged. 😄

The new Klein library was an attempt to modernize the code to make the project meet newer PHP paradigms and standards, while still allowing for easy loading and use. In fact, when using Klein in a more traditional fashion, there is not much that has changed in terms of its interface and usage. Due to the new structure, it has also been easier to add features to Klein and to use it in larger projects.

I have yet to do any benchmarking in terms of "new vs old", but the newer version's routing process is very similar. Yes, there are many more methods now and that could cause overhead at runtime, but its a fair trade-off. Really, the slowest part of most web applications is going to be the I/O time (database access, etc). In that case, Klein is a very tiny amount of overhead for what its giving you (a full HTTP kernel stack). Also, keep in mind that the old version was benchmarked on a Macbook Pro using a Core 2 duo. Fast forward to the new project (three years later), and we have more powerful hardware that can power this newer, more modular codebase. So, its hard (and a little unfair) to compare them 1-to-1. 😉

As far as including the library, yes you could easily include the library without composer by writing a PSR-0 compliant autoloader... but that's why Composer exists, so its better to not reinvent the wheel. You could also hard-include the library by manually including each class file, but that wouldn't be very maintainable.

The old version of Klein will not be receiving any new features, but if any critical errors come up, I can be sure to try and fix them (hey, I did that already). As far as where to get the older versions, they've all been tagged as previous releases, so you can find them on the tags/releases page.

Anyway, I hope I answered your questions efficiently. Don't be afraid to ask more! 😃

@gandaldf
Copy link
Author

Wow! Thank you very much Trevor! Your answers were very complete and exhaustive!
You should write this "intro" to explain better the project somewhere in the docs!

@Rican7
Copy link
Member

Rican7 commented Oct 31, 2013

Thank you @gandaldf! I'm really glad it helped! I was a little worried that it was too long, haha, but I wanted to make sure that it was all understood well. I might just add this to the wiki. 👍

@Rican7
Copy link
Member

Rican7 commented Dec 19, 2013

Hey @gandaldf, I've added an intro to the wiki: https://github.com/chriso/klein.php/wiki/Intro-to-Version-2
I thought you'd like to know. :)

@Rican7 Rican7 closed this as completed Dec 19, 2013
@ghost ghost assigned Rican7 Dec 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants