Closed pierresh closed 1 month ago
Does this example help you out in the streaming portion of the docs? https://docs.flightphp.com/learn/routing#streaming
Thanks for your quick feedback. I did not know it was possible to stream files :).
Unfortunately, I am using wildcards in my GET router because I have hundreds of routes, so I could not use the callback. I will try to submit a PR for a helper function to download files later this week.
Could you give me a pseudo code example of your codebase and how you're trying to do it? Maybe there's another way?
Actually, what I wish for is a simple way to handle files, as easy as using Flight::json()
for sending a JSON response.
I use a customized Kernel to load Controllers based on the route, so that I do not need to bother with registering all the routes (my app has several hundred). Basically, it looks like this:
Flight::route('GET|POST|PUT|DELETE|PATCH /@module/@name(/@id(/@sub_name(/@line)))', function($module, $name, $id, $sub_name, $line){
$request = Flight::request();
$kernel = new App\Kernel();
$kernel->handle($request);
});
I created a PR for this if you think this idea is interesting.
As the PR is now merged, I close this issue, thanks.
Hello,
I am sorry for this trivial question, but I wonder what is the cleanest way to download a file from an end-point with FightPHP? I could not see anything related in the documentation. Currently, I am doing as shown below, but in the same way that Symfony has
BinaryFileResponse
, maybe it would be better to have something similar?So far