當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ResponseFactory::stream方法代碼示例

本文整理匯總了PHP中Illuminate\Routing\ResponseFactory::stream方法的典型用法代碼示例。如果您正苦於以下問題:PHP ResponseFactory::stream方法的具體用法?PHP ResponseFactory::stream怎麽用?PHP ResponseFactory::stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Routing\ResponseFactory的用法示例。


在下文中一共展示了ResponseFactory::stream方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * ExportAll the selected entries.
  *
  * @param TableBuilder    $builder
  * @param ResponseFactory $response
  * @param array           $selected
  */
 public function handle(TableBuilder $builder, ResponseFactory $response, array $selected)
 {
     $model = $builder->getTableModel();
     $stream = $builder->getTableStream();
     $headers = ['Content-Disposition' => 'attachment; filename=' . $stream->getSlug() . '.csv', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Content-type' => 'text/csv', 'Pragma' => 'public', 'Expires' => '0'];
     $callback = function () use($selected, $model) {
         $output = fopen('php://output', 'w');
         /* @var EloquentModel $entry */
         foreach ($model->all() as $k => $entry) {
             if ($k == 0) {
                 fputcsv($output, array_keys($entry->toArray()));
             }
             fputcsv($output, $entry->toArray());
         }
         fclose($output);
     };
     $builder->setTableResponse($response->stream($callback, 200, $headers));
 }
開發者ID:jacksun101,項目名稱:streams-platform,代碼行數:25,代碼來源:ExportAll.php

示例2: stream

 /**
  * Return a new streamed response from the application.
  *
  * @param \Closure $callback
  * @param int $status
  * @param array $headers
  * @return \Symfony\Component\HttpFoundation\StreamedResponse 
  * @static 
  */
 public static function stream($callback, $status = 200, $headers = array())
 {
     return \Illuminate\Routing\ResponseFactory::stream($callback, $status, $headers);
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:13,代碼來源:_ide_helper.php


注:本文中的Illuminate\Routing\ResponseFactory::stream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。