PHPackages                             sassnowski/csv-schema - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. sassnowski/csv-schema

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

sassnowski/csv-schema
=====================

Turn your CSV files into objects. It's like an ORM for CSV!

0.4.1(8y ago)255.3k3[1 issues](https://github.com/ksassnowski/csv-schema/issues)[1 PRs](https://github.com/ksassnowski/csv-schema/pulls)MITPHP

Since Aug 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ksassnowski/csv-schema)[ Packagist](https://packagist.org/packages/sassnowski/csv-schema)[ RSS](/packages/sassnowski-csv-schema/feed)WikiDiscussions master Synced 1mo ago

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

CSV Schema Parser
=================

[](#csv-schema-parser)

[![Build Status](https://camo.githubusercontent.com/81adf9324d0f1adc5f1d6dc5abfe81747eb04ceb63570561f352aa0db102c15f/68747470733a2f2f7472617669732d63692e6f72672f6b736173736e6f77736b692f6373762d736368656d612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ksassnowski/csv-schema)[![Code Climate](https://camo.githubusercontent.com/938e929defc368bfd965b93805f1e983361b3a8db9ef15555144de9a5bf2666d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b736173736e6f77736b692f6373762d736368656d612f6261646765732f6770612e737667)](https://codeclimate.com/github/ksassnowski/csv-schema)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cc8431cf7c407329db29090e173d271bb5b8c0e3661bb7db727c6ba729334c02/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b736173736e6f77736b692f6373762d736368656d612f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ksassnowski/csv-schema/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/e3da4f77d327c39b630c62bd229e5c8376bc3e6ef4fc922874eb473772a54c5a/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65666338316333312d663933302d346439362d386339302d3631303464353030373838612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/efc81c31-f930-4d96-8c90-6104d500788a)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/ksassnowski/csv-schema/master/LICENSE.md)[![Current Release](https://camo.githubusercontent.com/e7375e4bab29957da62df491fb5a1bba965bb9b33db0303c9cced665522daaa1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d302e332e302d626c75652e737667)](https://img.shields.io/badge/release-0.4.1-blue.svg)

Have you ever wanted to have something like an ORM but for CSV files? No? Well now you can!

Introducing **CSV Schema Parser**. The number one way to turn your boring old CSV files into kick-ass PHP objects. And as if that wasn't amazing enough, it also casts your data to the correct data type! How cool is that? Not very cool you say? Well I disagree!

Installation
------------

[](#installation)

```
composer require sassnowski/csv-schema
```

Usage
-----

[](#usage)

First we have to define the schema of the CSV file we're about to parse. The schema is an associative array where the keys define what properties will be named on the resulting object. The values specify the data type of that column. The schema is ordered, meaning the first entry in the schema will correspond to the first column in the CSV and so on.

```
