{"id":21850573,"url":"https://github.com/fastbolt/entity-importer","last_synced_at":"2026-02-17T23:02:58.051Z","repository":{"id":42452178,"uuid":"471322228","full_name":"fastbolt/entity-importer","owner":"fastbolt","description":"Entity importing library for importing data from files (CSV and Excel currently) or API into doctrine.","archived":false,"fork":false,"pushed_at":"2026-01-27T09:24:17.000Z","size":185,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-27T21:07:12.666Z","etag":null,"topics":["data","doctrine2","excel","excel-import"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastbolt.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-03-18T10:19:39.000Z","updated_at":"2026-01-27T09:22:40.000Z","dependencies_parsed_at":"2024-11-28T00:46:28.444Z","dependency_job_id":null,"html_url":"https://github.com/fastbolt/entity-importer","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.29032258064516125","last_synced_commit":"e8d0d87c9f5f65bd9f863805cc0720eb6818da1d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/fastbolt/entity-importer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastbolt%2Fentity-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastbolt%2Fentity-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastbolt%2Fentity-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastbolt%2Fentity-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastbolt","download_url":"https://codeload.github.com/fastbolt/entity-importer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastbolt%2Fentity-importer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29561783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data","doctrine2","excel","excel-import"],"created_at":"2024-11-28T00:18:13.513Z","updated_at":"2026-02-17T23:02:58.033Z","avatar_url":"https://github.com/fastbolt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Composer version](https://img.shields.io/packagist/v/fastbolt/entity-importer)](https://packagist.org/packages/fastbolt/entity-importer)\n\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/fastbolt/entity-importer)](https://codeclimate.com/github/fastbolt/entity-importer)\n[![Test Coverage](https://img.shields.io/codecov/c/github/fastbolt/entity-importer)](https://app.codecov.io/gh/fastbolt/entity-importer/)\n\n[![Type Coverage](https://shepherd.dev/github/fastbolt/entity-importer/coverage.svg)](https://shepherd.dev/github/fastbolt/entity-importer)\n[![Psalm Level](https://shepherd.dev/github/fastbolt/entity-importer/level.svg)](https://shepherd.dev/github/fastbolt/entity-importer)\n\n[![Github Build](https://img.shields.io/github/actions/workflow/status/fastbolt/entity-importer/phpunit.yaml?branch=main)](https://github.com/fastbolt/entity-importer/actions)\n\n# Entity importing library\n\nThis library aims to provide an easy way to import files into doctrine entities.\n\n\n## Prerequisites\n\nFor now, the bundle is tested using PHP 7.4, 8.0 and 8.1.\n\nInternally, we rely on [PortPHP](https://github.com/portphp) and [Doctrine](https://github.com/doctrine/persistence)\n\n## Installation\n\nThe library can be installed via composer:\n\n```\ncomposer require fastbolt/entity-importer\n```\n\n## Configuration\n\nIf not configured automatically, the bundle needs to be enabled in your project's `bundles.php` file:\n\n```php\n\u003c?php\n\nreturn [\n    Fastbolt\\EntityImporter\\EntityImporterBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\n## Implementation\n\nThe only necessary code for new importers is the `Fastbolt\\EntityImporter\\EntityImporterDefinition` implementation. We recommend\nextending the abstract `Fastbolt\\EntityImporter\\AbstractEntityImporterDefinition` class.\n\nCurrently, two import sources are available: Csv and Xlsx.\n\n## Usage\n\nAfter implementing the above interface, the console command `entity_importer:import` will automatically recognize the new implementation.\n\nWhen executing the command without any arguments, it will display all available implementations:\n\n![Import command, overview of available importers](./docs/images/import-command-list.PNG)\n\n### Implementation example:\n\n```php\n\u003c?php\n\nnamespace App\\Component\\Data\\Import\\EntityImporter;\n\nuse App\\Entity\\Branch;use App\\Entity\\Material;use App\\Entity\\MaterialGroup;use App\\Repository\\BranchRepository;use App\\Repository\\MaterialGroupRepository;use App\\Repository\\MaterialRepository;use DateTime;use Doctrine\\Persistence\\ObjectRepository;use Fastbolt\\EntityImporter\\AbstractEntityImporterDefinition;use Fastbolt\\EntityImporter\\Reader\\CsvReader;use Fastbolt\\EntityImporter\\Types\\ImportSourceDefinition\\Csv;\n\n/**\n * @template-implements Material\n */\nclass MaterialImporterDefinition extends AbstractEntityImporterDefinition\n{\n\n    /**\n     * @var Csv\n     */\n    private Csv $importSourceDefinition;\n\n    /**\n     * @var MaterialRepository\n     */\n    private MaterialRepository $repository;\n\n    /**\n     * @var MaterialGroupRepository\n     */\n    private MaterialGroupRepository $materialGroupRepository;\n\n    /**\n     * @var BranchRepository\n     */\n    private BranchRepository $branchRepository;\n\n    /**\n     * @param MaterialRepository      $repository\n     * @param MaterialGroupRepository $materialGroupRepository\n     * @param BranchRepository        $branchRepository\n     */\n    public function __construct(\n        MaterialRepository $repository,\n        MaterialGroupRepository $materialGroupRepository,\n        BranchRepository $branchRepository\n    ) {\n        $this-\u003erepository              = $repository;\n        $this-\u003ematerialGroupRepository = $materialGroupRepository;\n        $this-\u003ebranchRepository        = $branchRepository;\n\n        $this-\u003eimportSourceDefinition = new Csv('MDMATERIALS.csv', CsvReader::TYPE);\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getName(): string\n    {\n        return 'materials';\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getDescription(): string\n    {\n        return 'Importer for Materials';\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getEntityClass(): string\n    {\n        return Material::class;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getIdentifierColumns(): array\n    {\n        return ['materialNumber', 'branch'];\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getFields(): array\n    {\n        return [\n            'materialGroup',\n            'branch',\n            'materialNumber',\n            'shortMaterialNumber',\n            'purchasingTextDe',\n            'purchasingTextEn',\n            'priceGroup',\n            'priceUnit',\n            'packingUnit',\n            'weight',\n            'purchasingAbcMark',\n            'language',\n            'availableSince',\n            'customsTariffNumber',\n            'ean',\n            'isOnlineMaterial',\n            'rangeIndicator',\n        ];\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getImportSourceDefinition(): Csv\n    {\n        return $this-\u003eimportSourceDefinition;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getRepository(): ObjectRepository\n    {\n        return $this-\u003erepository;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getFieldConverters(): array\n    {\n        return [\n            'branch'         =\u003e function ($value): Branch {\n                return $this-\u003ebranchRepository-\u003efind($value);\n            },\n            'materialGroup'  =\u003e function ($value): MaterialGroup {\n                return $this-\u003ematerialGroupRepository-\u003efindOneBy(['name' =\u003e $value]);\n            },\n            'priceUnit'      =\u003e static function ($value): int {\n                return (int)trim($value);\n            },\n            'availableSince' =\u003e static function ($value): ?DateTime {\n                if ('00000000' === $value) {\n                    return null;\n                }\n\n                return DateTime::createFromFormat('Ymd', $value);\n            },\n            'packingUnit'    =\u003e static function ($value): int {\n                return (int)trim($value);\n            },\n            'weight'         =\u003e static function ($value): float {\n                return (float)trim(str_replace(',', '', $value));\n            },\n        ];\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getSkippedFields(): array\n    {\n        return [\n            'language',\n        ];\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getEntityModifier(): ?callable\n    {\n        return static function (Material $material) {\n            $material-\u003esetIsProtected(true);\n        };\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastbolt%2Fentity-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastbolt%2Fentity-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastbolt%2Fentity-importer/lists"}