Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am getting problem with adding the behaviors #31

Open
kantsverma opened this issue Apr 11, 2016 · 3 comments
Open

I am getting problem with adding the behaviors #31

kantsverma opened this issue Apr 11, 2016 · 3 comments

Comments

@kantsverma
Copy link

When i am trying to add behavior inside src/Model/Table/ and then try export csv its giving me error not found any behavior. then after that non object of exportCsv()

@ProLoser
Copy link
Owner

Without looking at your code I can't help you man.

@cuong-tran
Copy link

I was having a difficult time figure out how to get it works. Probably you didn't setup plugin properly. Here is how I did it:

  1. Install plugin by composer:
composer require "proloser/cakephp-csv":"*@dev"
  1. Enable plugin in bootstrap:
Plugin::load('CakePHPCSV');

If you aren't using composer, instead you get the code directly from source then do this in your app root:

git clone https://github.com/ProLoser/CakePHP-CSV.git plugins/CakePHPCSV

then enable plugin in your bootstrap by:

Plugin::load('CakePHPCSV', ['autoload' => true]);
  1. Add the behavior in Table:
$this->addBehavior('CakePHPCSV.Csv', $options);
  1. Call method in Controller:
$this->Post->importCsv($filePath, $fields, $options);

Note:

  • Correct methods are importCsv/exportCsv, not import/export as wrongly put in document.
  • Calling importCsv($filePath, $options) without $fields would cause issue. Correct call should be importCsv($filePath, array(), $options).

@ProLoser
Copy link
Owner

Would you be willing to submit a pull request with the aforementioned corrections? I'm no longer actively maintaining this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants