Closed pradeshjm closed 7 years ago
I was able to get around this by adding a static route in ../config/routes/console.php
It is important to add the static routes BEFORE the variable route.
$app->get('/TraderFeed/getFeed', function (Request $request, Response $response, $args) use ($app, $argv) {
// .. my code here
});
// automatic console command resolver
$app->get('/{command}/{method}', function (Request $request, Response $response, $args) use ($app, $argv) {
$params = [];
<snip>
... variable route code here..
</snip
return $app->resolveRoute("\\App\\Console", $argv[0], $argv[1], $params);
});
Re-opening. The docs should point this out.
hi, I'm not quite sure i understand your question.
the App object is a singleton so you can get the app object anywhere using $app = \Lib\Framework\App::instance();
In my opinion the ideal is to have service providers or middleware to inject dependencies in the container and then add then have it automatically resolved in the (controller / console class) constructor or method but if you can also do \Lib\Framework\App::instance()->resolve('varName') to get something from the container anywhere in your code
The current method of creating CLI classes does not inject $app.
Having access to $app may be useful to access the environment or settings.