1. Go to this page and download the library: Download keboola/php-component library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
keboola / php-component example snippets
class Component extends \Keboola\Component\BaseComponent
{
protected function run(): void
{
// get parameters
$parameters = $this->getConfig()->getParameters();
// get value of customKey.customSubKey parameter and fail if missing
$customParameter = $this->getConfig()->getValue(['parameters', 'customKey', 'customSubKey']);
// get value with default value if not present
$customParameterOrNull = $this->getConfig()->getValue(['parameters', 'customKey'], 'someDefaultValue');
// get manifest for input file
$fileManifest = $this->getManifestManager()->getFileManifest('input-file.csv');
// get manifest for input table
$tableManifest = $this->getManifestManager()->getTableManifest('in.tableName');
// write manifest for output file
$this->getManifestManager()->writeFileManifest(
'out-file.csv',
(new OutFileManifestOptions())
->setTags(['tag1', 'tag2'])
);
// write manifest for output table
$this->getManifestManager()->writeTableManifest(
'data.csv',
(new OutTableManifestOptions())
->setPrimaryKeyColumns(['id'])
->setDestination('out.report'),
true // legacy manifest format flag
);
}
protected function customSyncAction(): array
{
return ['result' => 'success', 'data' => ['joe', 'marry']];
}
protected function getSyncActions(): array
{
return ['custom' => 'customSyncAction'];
}
}