PHPackages                             saxulum/saxulum-model-importer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. saxulum/saxulum-model-importer

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

saxulum/saxulum-model-importer
==============================

Saxulum Model Importer

2.1.0(9y ago)095MITPHPPHP ~5.5|~7.0

Since Jul 11Pushed 8y agoCompare

[ Source](https://github.com/saxulum-legacy/saxulum-model-importer)[ Packagist](https://packagist.org/packages/saxulum/saxulum-model-importer)[ RSS](/packages/saxulum-saxulum-model-importer/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (6)Used By (0)

saxulum-model-importer
======================

[](#saxulum-model-importer)

[![Build Status](https://camo.githubusercontent.com/4d3a434d5f119695268e986d599fcc629dc6d7557c75fef67649e5f055c3f837/68747470733a2f2f6170692e7472617669732d63692e6f72672f736178756c756d2f736178756c756d2d6d6f64656c2d696d706f727465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/saxulum/saxulum-model-importer)[![Total Downloads](https://camo.githubusercontent.com/7e04b35196e1ee75ff8ba2e98676bbc87a5c33366abe02078ff146ddb523e189/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f736178756c756d2d6d6f64656c2d696d706f727465722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/saxulum/saxulum-model-importer)[![Latest Stable Version](https://camo.githubusercontent.com/88c1a97a89ce75d80d5e4176bf1fb4e4ac91d7408eb2ba62c6fd54d8862f0326/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f736178756c756d2d6d6f64656c2d696d706f727465722f762f737461626c652e706e67)](https://packagist.org/packages/saxulum/saxulum-model-importer)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9a8c1b0e0b70684b2941cd03ba34a801d89bec169fbe18d49146b9b73d49b39a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736178756c756d2f736178756c756d2d6d6f64656c2d696d706f727465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/saxulum/saxulum-model-importer/?branch=master)

Description
-----------

[](#description)

A simple to use model importer, as a user you do not need to check if a create or update is needed, to loop...

Requirements
------------

[](#requirements)

- php: ~5.5|~7.0
- psr/log: ~1.0

Installation
------------

[](#installation)

Through [Composer](http://getcomposer.org) as [saxulum/saxulum-model-importer](https://packagist.org/packages/saxulum/saxulum-model-importer).

Usage
-----

[](#usage)

### Sample Implementation using Doctrine 2 ORM

[](#sample-implementation-using-doctrine-2-orm)

```
$em = ...

$importer = new Importer(new Reader($em), new Writer($em));
$importer->import();

```

```
class Reader implements ReaderInterface
{
    /**
     * @var EntityManager
     */
    protected $em;

    /**
     * @param EntityManager $em
     */
    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    /**
     * @ReaderModelInterface[]|array
     */
    public function getReaderModels($offset, $limit)
    {
        $qb = $this->em->getRepository(ReaderEntity::class)->createQueryBuilder('r');
        $qb->setFirstResult($offset);
        $qb->setMaxResults($limit);

        return $qb->getQuery()->getResult();
    }

    public function clearReaderModels()
    {
        $this->em->clear(ReaderEntity::class);
    }
}

```

```
class ReaderEntity implements ReaderModelInterface
{
    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $name;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param string $name
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @return int
     */
    public function getImportIdentifier()
    {
        return $this->getId();
    }
}

```

```
class Writer implements WriterInterface
{
    /**
     * @var EntityManager
     */
    protected $em;

    /**
     * @param EntityManager $em
     */
    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    /**
     * @param ReaderModelInterface $readerModel
     *
     * @return WriterModelInterface|null
     */
    public function findWriterModel(ReaderModelInterface $readerModel)
    {
        return $this->em->getRepository(WriterEntity::class)
            ->findOneBy(['importIdentifier' => $readerModel->getImportIdentifier()]);
    }

    /**
     * @param ReaderModelInterface $readerModel
     *
     * @return WriterModelInterface
     *
     * @throws NotImportableException
     */
    public function createWriterModel(ReaderModelInterface $readerModel)
    {
        $writerModel = new WriterEntity();
        $writerModel->setName($readerModel->getName());

        return $writerModel;
    }

    /**
     * @param WriterModelInterface $writerModel
     * @param ReaderModelInterface $readerModel
     *
     * @throws NotImportableException
     */
    public function updateWriterModel(WriterModelInterface $writerModel, ReaderModelInterface $readerModel)
    {
        $writerModel->setName($readerModel->getName());
    }

    /**
     * @param WriterModelInterface $writerModel
     *
     * @throws NotImportableException
     */
    public function persistWriterModel(WriterModelInterface $writerModel)
    {
        $this->em->persist($writerModel);
    }

    public function flushWriterModels(array $writeModels)
    {
        $this->em->flush($writeModels);
    }

    public function clearWriterModels()
    {
        $this->em->clear(WriterEntity::class);
    }

    /**
     * @param \DateTime $lastImportDate
     */
    public function removeWriterModels(\DateTime $lastImportDate)
    {
        $qb = $this->em->createQueryBuilder();
        $qb->delete(WriterEntity::class, 'w');
        $qb->where(
            $qb->expr()->orX(
                $qb->expr()->isNull('w.lastImportDate'),
                $qb->expr()->neq('w.lastImportDate', ':lastImportDate')
            )
        );
        $qb->setParameter('lastImportDate', $lastImportDate);

        $qb->getQuery()->execute();
    }
}

```

```
class WriterEntity implements WriterModelInterface
{
    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $name;

    /**
     * @var int
     */
    protected $importIdentifier;

    /**
     * @var \DateTime
     */
    protected $lastImportDate;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param string $name
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param int $importIdentifier
     */
    public function setImportIdentifier($importIdentifier)
    {
        $this->importIdentifier = $importIdentifier;
    }

    /**
     * @return int
     */
    public function getImportIdentifier()
    {
        return $this->importIdentifier;
    }

    /**
     * @param \DateTime $lastImportDate
     */
    public function setLastImportDate(\DateTime $lastImportDate)
    {
        $this->lastImportDate = $lastImportDate;
    }

    /**
     * @return \DateTime
     */
    public function getLastImportDate()
    {
        return $this->lastImportDate;
    }
}

```

Copyright
---------

[](#copyright)

Dominik Zogg

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

3636d ago

Major Versions

v1.x-dev → 2.0.02016-07-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/55048de83ca5e5d8c67164a19c78edcaad413b0c1a4ae10d92edf8d77bedd90f?d=identicon)[dominikzogg](/maintainers/dominikzogg)

---

Top Contributors

[![dominikzogg](https://avatars.githubusercontent.com/u/1011217?v=4)](https://github.com/dominikzogg "dominikzogg (29 commits)")

---

Tags

modelimportersaxulum

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/saxulum-saxulum-model-importer/health.svg)

```
[![Health](https://phpackages.com/badges/saxulum-saxulum-model-importer/health.svg)](https://phpackages.com/packages/saxulum-saxulum-model-importer)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.0k](/packages/composer-composer)[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514139.2M641](/packages/symfony-lock)[phpro/soap-client

A general purpose SoapClient library

8895.9M53](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k44](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[logiscape/mcp-sdk-php

Model Context Protocol SDK for PHP

368116.8k12](/packages/logiscape-mcp-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
