I am not getting any errors in the logs, and the CSV doesn't seem to download. I am trying to get the selected data from Views Bulk Operations into a csv that downloads upon the associated selected data with the Action extension that I am making:

I tried the VBO Export module, and the same thing happens.

EDIT: took out dots indicating that there were more rows so there isn't any confusion that that is what was in my code.

    public function executeMultiple(array $objects) {
        $tempFile = tempnam('/tmp', 'download_csv_');
        $out = fopen($tempFile, 'wb');
        if ($out) {
          fputcsv($out, array('Company Name'));
          foreach ($objects as $entity) {
            $company_name = $entity->getTitle() ?? 'Test';
            fputcsv($out, array($company_name));
          $headers = new ResponseHeaderBag();
          $headers->set('Content-Type', 'text/csv');
          $headers->set('Content-Disposition', 'attachment; filename="data.csv"');
          $headerArray = $headers->all();
          try {
           $response = new BinaryFileResponse($tempFile, 200, $headerArray, true);
          }catch(Exception $e) {
          return $response;
  • What is the code snippet representing as pertaining to the Question? If that is your custom code, it doesn't contain valid PHP syntax. It can't work as written.
    – mona lisa
    Commented May 24 at 17:43
  • This is my custom code that extends views bulk operations that pertains to the question. I also tried VBO Export module with no code with the same results. Do you know what is wrong with my custom code above that extends views bulk operations? Drush cr is working okay and I don't get any errors in watchdog logs Commented May 24 at 18:00
  • I also don't get a WSOD. Commented May 24 at 18:20
  • 1
    You won't find any errors because there aren't any - executeMultiple is a void function, the response you're returning just isn't used for anything. It's possible to override the completion redirect (see drupal.org/project/views_bulk_operations/issues/3042535 & drupal.org/project/views_bulk_operations/issues/3207304), so in theory you could redirect to a route with a force-download, but it would leave your users on the batch page, rather than taking you back to the start. Weird UX. The standard solution for this in my experience is to save the file, and render a...
    – Clive
    Commented May 24 at 20:25
  • 1
    ...message with a link to it on batch completion. Or you might be able to hack something with javascript/meta refresh tags on the completion page to redirect to a route serving the force-download, but it'd be messy
    – Clive
    Commented May 24 at 20:25

1 Answer 1


Thanks to @clive, I was able to find the pertinent issue links. Based on the information I found, I just needed to create a new views table and VBO Export works.


I was also hiding the message box, so that is why I couldn't see VBO Export's link. I didn't think a link to download the file would appear there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.