1. Go to this page and download the library: Download proloser/cakephp-csv 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/ */
proloser / cakephp-csv example snippets
$options = array(
// Refer to php.net fgetcsv for more information
'length' => 0,
'delimiter' => ',',
'enclosure' => '"',
'escape' => '\\',
// Generates a Model.field headings row from the csv file
'headers' => true,
// If true, String $content is the data, not a path to the file
'text' => false,
)
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\Table;
/**
* Posts Model
*/
class PostsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
//$options = ...
$this->addBehavior('CakePHPCSV.Csv', $options);
}
}