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. tableau-mkt/eggs-n-cereal

AbandonedArchivedLibrary

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

A basic PHP XLIFF serialization library.

0.0.7(9y ago)611.4k6[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 ago12 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 1mo ago

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 75% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community17

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

3610d 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

[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[flowwow/cloudpayments-php-client

cloudpayments api client

2188.2k](/packages/flowwow-cloudpayments-php-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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