bowphp / csv
CSV formatter for Bowphp
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/bowphp/csv
Requires
- league/csv: ^9.0@dev
Requires (Dev)
- bowphp/framework: 5.x-dev
- phpunit/phpunit: 12.5.x-dev
This package is auto-updated.
Last update: 2025-12-28 13:24:07 UTC
README
A tiny helper to export and import Eloquent-like models to/from CSV using league/csv.
Installation
composer require bowphp/csv
Quick start
- Add the
Bow\Csv\Csvtrait to your model:
use Bow\Csv\Csv; use Bow\Database\Barry\Model; class User extends Model { use Csv; }
- Export a CSV string (optionally restrict columns):
$user = new User(); $user->setCsvHeaders(['id', 'name']); $csv = $user->toCsv(); // returns the CSV as a string
- Import rows from a CSV file into your model:
$user = new User(); $user->importCsv('/path/to/file.csv', ['id', 'name', 'email']);
Helper functions are also available:
app_export_model_to_csv(new User(), null, ['id', 'name']); app_import_csv_to_model(new User(), '/path/to/file.csv', ['id', 'name', 'email']);
Contributing
- Fork and create a topic branch.
- Install deps:
composer install. - Run tests:
./vendor/bin/phpunit tests --bootstrap=vendor/autoload.php. - Submit a PR with a clear description of the change.