[League\CSV] Review version 9.0

58 views
Skip to first unread message

ignace nyamagana butera

unread,
Mar 6, 2017, 4:53:34 AM3/6/17
to thephpleague
For those interested a new major version of League\Csv is on preparation.

There is a lot of API break between v8 and v9 so If anyone is interested to review the new API for possible changes/adaptation now is the perfect time. Just head to https://github.com/thephpleague/csv and install the master branch and review its usage.

The documentation is complete and can already be found here http://csv.thephpleague.com/9.0/

The TL;DR on what's new:

- improved PHP stream filtering supports
- improved Writer error handling
- improved Extracting records by introducing a Constraint Builder class and a CSV Records Collection class

Thanks in advance.

Woody Gilk

unread,
Mar 10, 2017, 9:47:13 AM3/10/17
to ignace nyamagana butera, thephpleague
I generally like what I see in v9 in terms of separation of concerns:

- automatic BOM stripping is a plus for usability
- the separation of Statement makes a ton of sense

However, I do worry that some of these changes makes the package harder to use and less intuitive:

- using setHeaderOffset() feels much less obvious than fetchAssoc()
- having to call select() before fetchAll() is not intuitive
- I feel like the relationship between Statement and Reader should be flipped:

Instead of writing:

$statement = (new Statement());
$records = $reader->select($statement);

Would it be more obvious to do the following?

$statement = (new Statement());
$records = $statement->fetch($reader);


To be clear, I feel like the ideas behind v9 are really good but the execution feels a bit rushed. I think for the average user, v9 will feel less intuitive and be harder to work with. A little more thought put into the ergonomics would go a long way to make it clearly better than v8.

Just my $0.02!

--
You received this message because you are subscribed to the Google Groups "thephpleague" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thephpleague+unsubscribe@googlegroups.com.
To post to this group, send email to thephp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/thephpleague/3b055991-89ff-4a24-8baa-edc0b8085f56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ignace nyamagana butera

unread,
Mar 10, 2017, 10:01:39 AM3/10/17
to thephpleague, nyam...@gmail.com
Thanks for the review Woody,

Regarding the Statement object use you can do both.

 $reader->select($stmt) is equivalent to $stmt->process($reader);

Maybe this is not well written in the doc but it is there. see http://csv.thephpleague.com/9.0/reader/statement/#apply-the-constraints-to-a-csv-document

As for Reader::select, to me it feels like you could view the Reader as connection type (I like the comparison to PDO):
- you instantiate a connection to your CSV using the Reader.
- Then you setup the connection properties using the set* methods (setDelimiter, setHeaderOffset, addStreamFilter, and so forth...)
- Finally you select records using the Reader::select method and the Statement object which returns the RecordSet.

To me this is more intuitive that the current public API.
To unsubscribe from this group and stop receiving emails from it, send an email to thephpleague...@googlegroups.com.

ignace nyamagana butera

unread,
Apr 5, 2017, 5:03:29 PM4/5/17
to thephpleague, nyam...@gmail.com
Since the last review more separations were done:

The conversion methods were removed from the RecordSet object and move into their own classes as explained in the documentation:
http://csv.thephpleague.com/9.0/converter/

and a new method AbstractCsv:chunk was added to help output large CSV files see http://csv.thephpleague.com/9.0/connections/output/#outputting-the-document-into-chunks

As usual since we are in review period your input/remarks are more than welcomed
Reply all
Reply to author
Forward
0 new messages