Comments (4)
That would be sexy. I don't know what the performance cost of __invoke()
would be though
from klein.php.
I'm not incredibly concerned with the performance characteristics of __invoke()
, only because most projects (insert made-up percentage statistic here) don't use the return value of the respond()
method anyway, and even so would most likely not use it in performance-heavy tasks or in multiple places.
Besides, I think that the benefits of "classifying" the route callbacks outweigh the potential performance hit that correlates with a small percentage of developers actually using the respond()
return value. 👅
I'm glad you like the idea, though. And yea, questioning performance is never a bad idea.
from klein.php.
Boom! So far this is coming along nicely in my branch: https://github.com/Rican7/klein.php/tree/feature/routes-as-objects
I have a new Route
class and the Klein respond()
method is now creating a new Route instance and then passing back the instance for chainable calling. :)
What I still need to work on:
- Converting the
$routes
array into a class/data-structure of some kind - More Route class meta (like names and reverse routing?)
- And a more generic
add()
method in the Klein class for simply adding Route object instances to the Klein routes data-structure without having to go through therespond()
method. This allows:- Extendable
Route
classes by using dependency injection - Custom Route object definitions external of the
respond()
method
- Extendable
from klein.php.
Names and reverse routing will be in their own feature branch and PR.
For now, though, this is implemented and closed. :)
from klein.php.
Related Issues (20)
- Broken link in README
- JSON pretty print HOT 1
- PHP warning array_flip()
- Multiple instances? HOT 1
- How could we use DI with this package HOT 1
- subroute not working HOT 5
- Klein dispatch() LockedResponseException HOT 2
- $this->PageTitle is not working HOT 2
- is it possible to create methods with parameters in $app->register HOT 1
- Question, handling a client area HOT 2
- Headers not sent if buffer length exceedes value defined in ini.output_buffering
- More concise, Laravel-style Controller@method callbacks HOT 3
- Error with SVG images HOT 2
- Support apcu without apcu_bc?
- Central callback/hook before route response is called HOT 1
- is this package still maintained? HOT 4
- Access "pathname()" method in view using $this->pathname()
- Question: how use parameter in route?
- Add more better regex's
- Second Subdirectory Routing Not Working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from klein.php.