PortPHP¶
This is the documentation for PortPHP, an awesome data import/export pipeline:
<?php
use Port\Csv\CsvReader;
use Port\Doctrine\DoctrineWriter;
$reader = new CsvReader('input.csv');
$writer = new DoctrineWriter($entityManager, 'YourApp:Person');
$writer->prepare();
// Iterate over the reader and write each row to the database
foreach ($reader as $row) {
$writer->write($row);
}
$writer->finish();
Overview¶
Broadly speaking, you can use PortPHP in two ways:
- organize your import/export pipeline around a workflow; or
- use one or more of the components on their own, such as readers, writers or converters.
Installation¶
Open a command console, enter your project directory and execute the following command to download the latest stable version of this package:
$ composer require portphp/steps:1.0.x-dev
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Components¶
Port consists of several components to aid you in processing data:
- Readers read data of different kinds from different sources.
- Writers write data to a database, Excel or CSV file.
- Value converters transform your input data and clean it up.
- Each of these components can be used standalone. However, you can structure the components around a Workflow for better re-usability.