smichaelsen / caldera-php
Caldera Records Parser
Installs: 36 446
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12.1
- phpunit/phpunit: ^6
README
Caldera helps you to import data from sources like XML or CSV, to map, transform and validate them according to your needs and provides them with small memory footprint.
$csvInputGenerator = new \Smichaelsen\Caldera\InputGenerator\CsvInputGenerator();
$csvInputGenerator->setCsvHandle(fopen(__DIR__ . '/test-equestrian.csv', 'r'));
foreach (\Smichaelsen\Caldera\RecordMapper::mapRecords(
$csvInputGenerator,
new MyMappingClass()
) as $record) {
// $record is mapped, validated and processed according to rules in your MyMappingClass()
}
Caldera works line by line (record by record) when possible (not possible with XML) and this way saves memory. This enables you to import data from a huge CSV file for example.
Run tests:
composer update --prefer-lowest --prefer-stable
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests
composer update
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests