A better way of extracting data from a FIT file

I have some software that extracts data from FIT files to present to athletes. I extract the data using FitCSVTool.jar, which spits out myfilename_data.csv - I then parse this data row by row to extract arrays of values for the following:

record.*

lap.*

length.*

session.*

activity.*

file_id.*

set.*

I then piece these together in a format I can use. For example, I make use of the timestamps in lap.* to partition the record.* values into laps.

This approach can be fairly slow (several seconds to parse large files), but I process about a million files a year and it has worked extremely well for about 15 years.

However, it's been suggested to me (and I've always suspected) that there's a better way to extract the data I need from a FIT file.

I program in PHP. I use a simple exec() call to run a bash script that in turn runs FitCSVTool.jar, passing it a fit file location.

I'm not especially familiar with the intricacies of other languages.

Could anyone point me at some simple examples of a best practice approach that would return the sort of data that I need?

Many thanks!