Ram Chander
Ram Chander

Reputation: 1522

How to generate CSV file in cakePHP 2.x?

I am beginner in cakePHP and woking on cakePHP 2.0. I am trying to generate CSV file, to accomplish this task i am using the following method.

cake php official site refr.

github refr.

i have got stucked in step no. 2 when it is loading the plugin. the following error is occurring in app/Config/bootstrap.php file

Fatal error: Class 'CakePlugin' not found in /var/www/html/sitefolder/app/config/bootstrap.php on line 51

CakePlugin::load('Export');

Please correct me. Thnaks

Upvotes: 2

Views: 3726

Answers (1)

Ram Chander
Ram Chander

Reputation: 1522

Thnaks guys for your precious response on this

For now i have find the solution of this by following steps.

  1. download the plugin files form https://github.com/joshuapaling/CakePHP-Export-CSV-Plugin

  2. by pass the step no.2 and step no.3 of what they have mentioned in official refer.

  3. copy the file "ExportComponent.php" from plugin and paste it in

    site_folder/app/controllers/components

  4. add it in controller's component array variable

    $components = array('blabla1', 'blabal2', 'Export')

  5. create $data array variable (which contains the csv file data ) and just do like

    $this->Export->exportCsv($data, 'filename1.csv');

Its done and working fine for me

Upvotes: 2

Related Questions