Comments (9)
I think this could be a good recipe. Doing this by default I think is slightly confusing to someone who is used to closures in PHP right now. If we default this behavior, then we have BC issues.
It is too bad we can't define the variable on creation of the closure.
from silex.
What kind of BC issues? Closure use-statements will still work.
from silex.
@awildeep the point is that this requires changes in the core so it cannot be done as a recipe.
from silex.
@igorw the issue would be for routes. If the app is passed as first argument by the Application and you don't update your code, you have an issue because you expect to get the first routing placeholder as first argument.
from silex.
@stof; Yea I see your point. I didn't catch it before in a quick glance.
@igorw; stof explained my BC issue. For some clarity if I have existing code like:
$app->get('/test/{variable}', function ($variable) use ($app) { ....});
It would change to this:
$app->get('/test/{variable}', function ($app, $variable) { ....});
This effectively forces any existing code to need to be reworked, thus breaking BC. Not a big deal to me right now as this is a fairly simple change, but existing developers may not know how to handle the change and cause a lot of issue tickets after they upgrade.
Just as a side note: I like this change and I am for it, if I gave you a negative impression my bad. I am just concerned about existing applications.
from silex.
No, my suggestion is to use a param converter, and check if there is a $app
argument. So it will be injected based on the name (or the type, through type hinting).
from silex.
Edited; I removed my question, no need to ask it.
Also; this is much better than I thought it was. I guess this will encourage developers to always name their application object $app more as well for consistency.
from silex.
Hello there, this is already possible thanks to @fabpot.
See: 934bf3e
from silex.
Yep, it works through type hinting, which I suggested as an alternative. Closing this, thanks!
from silex.
Related Issues (20)
- MessageSelector Deprecated HOT 1
- Swiftmailer SSL stream_context_options cannot be set HOT 1
- When twig.path is an array the key is expected to be the path and the value the namespace, why? HOT 2
- REDACTED HOT 5
- New Module Integration HOT 3
- Enable annotations for the (symfony) validator HOT 8
- silex and symfony 4 HOT 2
- "Welcome!" page with $app['debug'] = true HOT 5
- Make Silex-Providers a separate project HOT 7
- New maintainers needed. Keep Silex alive. HOT 27
- Update silex.symfony.com about Silex end of life HOT 2
- Last security error is not translated HOT 3
- Error after update to v2.2.3 HOT 15
- Broken Guard in SecurityProvider? HOT 2
- #silex-php on freenode HOT 2
- The #1611 patch does not treat the user provider as a service HOT 1
- Rebuild your code HOT 2
- Middleware handlers with controller-like argument-resolving HOT 1
- context logic HOT 2
- missing request_stack check in TwigServiceProvider
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 silex.