PHP code example of legow / zend-view-csvstrategy

1. Go to this page and download the library: Download legow/zend-view-csvstrategy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

legow / zend-view-csvstrategy example snippets


         

        return [
            'view_manager' => [
                'template_path_stack' => [
                    __DIR__ . '/../view',
                ],
                'template_map' => [
                    'export/csv' => __DIR__.'/../view/refuels/index/export.pcsv'
                ],
                'strategies' => [
                    View\Strategy\CsvStrategy::class
                ]
            ]
        ]
    

         

        foreach($this->data as $row) {
            echo implode($row, ';').PHP_EOL;
        }
    

        

        namespace Test;

        use LegoW\View\Model\CsvModel;

        class TestController extends AbstractActionController
        {
            public function indexAction()
            {
                $view = new CsvModel();
                $view->setTerminate(true)
                     ->setVariables([
                         "data" => [
                             range(1,26),
                             range('a','z')
                         ]
                     ]);
                return $view;
            }
        }