PHPackages                             proloser/cakephp-csv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. proloser/cakephp-csv

ActiveCakephp-plugin[Utility &amp; Helpers](/categories/utility)

proloser/cakephp-csv
====================

2.0(7y ago)5223.6k↓45.7%41[2 PRs](https://github.com/ProLoser/CakePHP-CSV/pulls)PHPPHP &gt;=5.4.16

Since May 5Pushed 7y ago6 watchersCompare

[ Source](https://github.com/ProLoser/CakePHP-CSV)[ Packagist](https://packagist.org/packages/proloser/cakephp-csv)[ RSS](/packages/proloser-cakephp-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

CSV Plugin
==========

[](#csv-plugin)

Allows the importing and exporting of a standard $this-&gt;data formatted array to and from csv files. Doesn't currently support HABTM.

Options
-------

[](#options)

Importing, exporting and setup come with the same options and default values

```
$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,
)
```

Instructions
------------

[](#instructions)

- Add Behavior to the table

```

```

### Importing

[](#importing)

- Upload a csv file to the server
- Import the csv file into your data variable:

**Approach 1:** Use a CSV file with the first row being Model.field headers

```
Posts.csv
Post.title, Post.created, Post.modified, body, user_id, Section.name, Category.0.name, Category.0.description, Category.1.name, Category.1.description
..., ..., ...
```

```
$this->data = $this->Posts->import($content, $options);
```

**Approach 2:** Pass an array of fields (in order) to the method

```
$data = $this->Posts->import($content, array('Post.title', 'Post.created', 'Post.modified', 'body', 'user_id', 'Category.0.name', 'Category.0.description', 'Category.1.name', 'Category.1.description'));
```

- Process/save/whatever with the data

```
$entities = $this->Posts->newEntities($data);
$Table = $this->Posts;
$Table->connection()->transactional(function () use ($Table, $entities) {
    foreach ($entities as $entity) {
        $Table->save($entity, ['atomic' => false]);
    }
});
```

### Exporting

[](#exporting)

- Populate an $this-&gt;data type array

```
$data = $this->Post->find()->all();
```

- Export to a file in a writeable directory

```
$this->Posts->exportCsv($filepath, $data, $options);
```

### Additional optional callbacks:

[](#additional-optional-callbacks)

- `beforeImportCsv($filename, $fields, $options)` returns boolean $continue
- `afterImportCsv($data)`
- `beforeExportCsv($filename, $data, $options)` returns boolean $continue
- `afterExportCsv()`

### FAQ

[](#faq)

#### Incorrect Line Endings (OSX)

[](#incorrect-line-endings-osx)

Some people [have mentioned](https://github.com/ProLoser/CakePHP-CSV/issues/6) having incorrect line endings. This can be fixed by having this in your php codebase:

```
ini_set("auto_detect_line_endings", true);

```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 51.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1110 days

Total

2

Last Release

2732d ago

Major Versions

1.0 → 2.02018-11-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/62983b1a01e5883ec177954371582558a8c9788c82a8ee1b35a2ef7d164c5474?d=identicon)[ProLoser](/maintainers/ProLoser)

---

Top Contributors

[![ProLoser](https://avatars.githubusercontent.com/u/67395?v=4)](https://github.com/ProLoser "ProLoser (19 commits)")[![rochamarcelo](https://avatars.githubusercontent.com/u/850748?v=4)](https://github.com/rochamarcelo "rochamarcelo (9 commits)")[![challgren](https://avatars.githubusercontent.com/u/88909?v=4)](https://github.com/challgren "challgren (2 commits)")[![paulleephp](https://avatars.githubusercontent.com/u/2199146?v=4)](https://github.com/paulleephp "paulleephp (2 commits)")[![webnard](https://avatars.githubusercontent.com/u/1213808?v=4)](https://github.com/webnard "webnard (1 commits)")[![JacopKane](https://avatars.githubusercontent.com/u/68406?v=4)](https://github.com/JacopKane "JacopKane (1 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (1 commits)")[![emacaste](https://avatars.githubusercontent.com/u/4621873?v=4)](https://github.com/emacaste "emacaste (1 commits)")[![krecik](https://avatars.githubusercontent.com/u/324543?v=4)](https://github.com/krecik "krecik (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/proloser-cakephp-csv/health.svg)

```
[![Health](https://phpackages.com/badges/proloser-cakephp-csv/health.svg)](https://phpackages.com/packages/proloser-cakephp-csv)
```

###  Alternatives

[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

338920.1k32](/packages/dereuromark-cakephp-tools)[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

18238.1k2](/packages/civicrm-civicrm-drupal-8)[dereuromark/cakephp-dto

A CakePHP plugin for generating immutable Data Transfer Objects with full type safety

2988.9k3](/packages/dereuromark-cakephp-dto)[loadsys/cakephp_sitemap

A CakePHP Plugin for adding automatic XML and HTML Sitemaps to an app

2819.6k](/packages/loadsys-cakephp-sitemap)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
