2017 © Pedro Peláez
 

cakephp-plugin csv_simple

CakePHP plugin which handle csv data

image

oppara/csv_simple

CakePHP plugin which handle csv data

  • Tuesday, January 12, 2016
  • by oppara
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

CsvSimple

Build Status, (*1)

handle csv data, (*2)

Requirements

  • PHP >= 5.5
  • CakePHP >= 2.6

Installation

composer.json, (*3)

{
    "require": {
        "oppara/csv_simple": "*"
    }
}

Enable plugin

app/Config/bootstrap.php:, (*4)

CakePlugin::load('CsvSimple'); or CakePlugin::loadAll();, (*5)

Sample

<?php
App::uses('AppController', 'Controller');
App::uses('CsvImportComponent', 'CsvSimple.Controller/Component');
App::uses('CsvExportComponent', 'CsvSimple.Controller/Component');

class FooController extends AppController
{
    public $components = [
        'CsvSimple.CsvImport',
        'CsvSimple.CsvExport',
    ];

    public $uses = [
        'Bar',
    ];

    public function import()
    {
        if ($this->request->is('get')) {
            return;
        }

        try {
            $csv = Hash::get($this->request->data, 'Csv.file');

            $this->CsvImport->headerRows = 1;
            $gen = $this->CsvImport->createGenerator($csv);

            $this->Bar->begin();
            foreach ($gen as $idx => $row) {
                $this->Bar->import($row);
            }
            $this->Bar->commit();
        }
        catch(Exception$e) {
            $this->Bar->rollback();
            $this->set('error', $e->getMessage());
        }
    }

    public function download()
    {
        try {
            $filename = date('Ymdhis') . '.tsv';
            $this->CsvExport->delimiter = "\t";

            $data = $this->Bar->find('all');
            $this->CsvExport->download($data, $filename);
        }
        catch(Exception$e) {
            $this->set('error', $e->getMessage());
        }
    }

    public function export()
    {
        try {
            $path = '/path/to/export.csv';

            $fields = $this->Bar->getHeaderFields();
            $this->CsvExport->setHeader($fields);

            $data = $this->Bar->find('all');
            $this->CsvExport->export($data, $path);
        }
        catch(Exception$e) {
            $this->set('error', $e->getMessage());
        }
    }

The Versions

12/01 2016

dev-master

9999999-dev https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

12/01 2016

0.0.8

0.0.8.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

13/12 2015

0.0.7

0.0.7.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

16/11 2015

0.0.6

0.0.6.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

03/11 2015

0.0.5

0.0.5.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

29/10 2015

0.0.4

0.0.4.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

25/10 2015

0.0.3

0.0.3.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

24/10 2015

0.0.2

0.0.2.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp

21/10 2015

0.0.1

0.0.1.0 https://github.com/oppara/cakephp-plugin-csv_simple

CakePHP plugin which handle csv data

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar oppara

csv cakephp