PHPackages                             tableau-mkt/eggs-n-cereal - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. tableau-mkt/eggs-n-cereal

AbandonedArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

tableau-mkt/eggs-n-cereal
=========================

A basic PHP XLIFF serialization library.

0.0.7(10y ago)611.6k5[1 issues](https://github.com/tableau-mkt/eggs-n-cereal/issues)[3 PRs](https://github.com/tableau-mkt/eggs-n-cereal/pulls)GPL-2.0+PHP

Since Dec 24Pushed 4y ago4 watchersCompare

[ Source](https://github.com/tableau-mkt/eggs-n-cereal)[ Packagist](https://packagist.org/packages/tableau-mkt/eggs-n-cereal)[ RSS](/packages/tableau-mkt-eggs-n-cereal/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

Eggs'n'Cereal
=============

[](#eggsncereal)

A basic, generic PHP XLIFF serialization library.

### Installation

[](#installation)

The recommended way to install Eggs'n'Cereal is of course to use Composer:

```
{
  "require": {
    "tableau-mkt/eggs-n-cereal": "@dev"
  }
}
```

**Note**: There is no stable release, necessarily. So...

### Usage

[](#usage)

The basic idea of this library is that you provide a series of "translatable" classes for your entities. These "translatable" classes implement the `EggsCereal\Interfaces\TranslatableInterface` interface.

A `TranslatableInterface` instance is meant to wrap your entity with a unified method to get and set data. You must do so by implementing:

- `TranslatableInterface::getData()`
- `TranslatableInterface::setData()`

In addition to getting and setting data, you must also provide a way to get a unique identifier for your translatable entity, as well as a label by implementing:

- `TranslatableInterface::getIdentifier()`
- `TranslatableInterface::getLabel()`

The identifier and label are used to validate an XLIFF file during the import / unserialization process.

Once you've implemented the interface, you can serialize and unserialize your translatable like so:

```
// Generated by composer.
require_once('vendor/autoload.php');

// Instantiate your translatable here.
$yourTranslatable = new YourTranslatable(/*...*/);

// Instantiate the serializer:
$xliffSerializer = new EggsCereal\Serializer();
$targetLanguage = 'pt-br';

// Serialize your translatable like so:
$xlf = $xliffSerializer->serialize($yourTranslatable, $targetLanguage);

// Unserialize an xliff file like so:
$translatedFile = file_get_contents('/path/to/translated-pt-br.xlf');
$xliffSerializer->unserialize($yourTranslatable, $targetLanguage, $translatedFile);
```

### Sample implementation

[](#sample-implementation)

Suppose you want to translate data stored in a flat, single-level PHP array. You might write an `ArrayTranslatable` class like so:

```
use EggsCereal\Interfaces\TranslatableInterface;

class ArrayTranslatable implements TranslatableInterface {

  public $data = array();

  public function __construct(array $data) {
    $this->data = $data;
  }

  /**
   * {@inheritdoc}
   */
  public function getData() {
    $response = array();

    // Iterate through each item in the array.
    foreach ($data as $key => $value) {
      // For each item, set a #label and #text value.
      $response[$key] = array(
        '#label' => $key,
        '#text' => $value,
      );
    }

    return $response;
  }

  /**
   * {@inheritdoc}
   */
  public function setData(array $data, $targetLanguage) {
    foreach ($data as $key => $value) {
      $this->data[$key] = $value['#text'],
    }
  }

  // Note, you'll also need implementations for getIdentifier() and getLabel().
}
```

With this `ArrayTranslatable` implementation, usage is straightforward.

```
$xliffSerializer = new EggsCereal\Serializer();
$targetLang = 'fr-fr';

$arrayTranslatable = new ArrayTranslatable(array(
  'foo' => 'Translatable foo value',
  'bar' => 'Translatable bar value',
));

// Generate an XLIFF file from your translatable.
$xlf = $xliffSerializer->serialize($arrayTranslatable, $targetLang);

// Import a translated XLIFF file.
$translatedFile = file_get_contents('/path/to/translated-array-fr-fr.xlf');
$xliffSerializer->unserialize($translatable, $targetLang, $translatedFile);

// Now, your array will be translated and might be available like so:
print_r($arrayTranslatable->data);
array(
  'foo' => 'Valeur de foo traduisible',
  'bar' => 'Valeur de bar traduisible',
);
```

### Forewarning

[](#forewarning)

This library is a work in progress and draws heavily from work by Cloudwords on their [Cloudwords for Multilingual Drupal](https://www.drupal.org/project/cloudwords)module.

Use at your own risk, for now.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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 ~91 days

Recently: every ~127 days

Total

7

Last Release

3662d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a254a7f633f8b40b08716690264805d4f602e6b6a298e067027544495b9ee2a0?d=identicon)[iamEAP](/maintainers/iamEAP)

---

Top Contributors

[![iamEAP](https://avatars.githubusercontent.com/u/3496491?v=4)](https://github.com/iamEAP "iamEAP (18 commits)")[![SayTen](https://avatars.githubusercontent.com/u/619112?v=4)](https://github.com/SayTen "SayTen (2 commits)")[![svc-scm](https://avatars.githubusercontent.com/u/48930134?v=4)](https://github.com/svc-scm "svc-scm (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tableau-mkt-eggs-n-cereal/health.svg)

```
[![Health](https://phpackages.com/badges/tableau-mkt-eggs-n-cereal/health.svg)](https://phpackages.com/packages/tableau-mkt-eggs-n-cereal)
```

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k869.4M8.8k](/packages/symfony-http-kernel)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

187557.3k3](/packages/wikimedia-parsoid)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[ecotone/ecotone

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

564576.7k53](/packages/ecotone-ecotone)

PHPackages © 2026

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