PHPackages                             php-enspired/peekaboo - 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. php-enspired/peekaboo

ActiveLibrary

php-enspired/peekaboo
=====================

message formatting utilities using ICU, with a fallback on basic string templating.

v2.0(9mo ago)1241MPL-2.0PHP ^8.3

Since Mar 14Pushed 9mo agoCompare

[ Source](https://github.com/php-enspired/peekaboo)[ Packagist](https://packagist.org/packages/php-enspired/peekaboo)[ Docs](http://php.enspi.red)[ RSS](/packages/php-enspired-peekaboo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

[![](https://camo.githubusercontent.com/f9cd7d654ff3b337fdfcb5e9a7adbad709880e03f57c1c4c308c7fccc6488374/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7068702d656e7370697265642f7065656b61626f6f2e737667)](https://camo.githubusercontent.com/f9cd7d654ff3b337fdfcb5e9a7adbad709880e03f57c1c4c308c7fccc6488374/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7068702d656e7370697265642f7065656b61626f6f2e737667) [![](https://camo.githubusercontent.com/b63a5fc65903e6c0c39c065b10efc3a6a1c08555aad6be1d63e2ee5b0c71a2b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d626c75652e7376673f636f6c6f72423d383839324246)](https://camo.githubusercontent.com/b63a5fc65903e6c0c39c065b10efc3a6a1c08555aad6be1d63e2ee5b0c71a2b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332d626c75652e7376673f636f6c6f72423d383839324246) [![](https://camo.githubusercontent.com/35bcbe44160d7e0a3efe93a55f55071e05da59638fa735808c6d32764cf14e63/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d504c2e322e302d6f72616e67652e737667)](https://camo.githubusercontent.com/35bcbe44160d7e0a3efe93a55f55071e05da59638fa735808c6d32764cf14e63/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d504c2e322e302d6f72616e67652e737667)

peekaboo! (ICU)
===============

[](#peekaboo-icu)

*peekaboo* provides message formatting utilities using International Components for Unicode, with a fallback on basic string templating.

dependencies
------------

[](#dependencies)

Requires php 8.3 or later.

ICU support requires the `intl` extension. Building ICU resource bundles uses `genrb`.

installation
------------

[](#installation)

Recommended installation method is via [Composer](https://getcomposer.org/): simply `composer require php-enspired/peekaboo`.

for starters
------------

[](#for-starters)

```
use at\peekaboo\ {
  HasMessages,
  MessageMapper
};

class Foo implements HasMessages {
  use MessageMapper;
}

$formatted = new Foo()->makeMessage("foo.welcome", ["place" => "jungle"]);
// Welcome to the jungle, we've got fun and games
```

message registry
----------------

[](#message-registry)

Where did that message come from? *peekaboo* provides a registry for your application to store, lookup, and format messages. You can register any intl `ResourceBundle`, either available by default or under a named group, and get formatted messages by passing the message key and substitution context.

If a message key is not found under the specified group name, peekaboo falls back on looking in the default registries. You can also set a default locale (used when `$locale` is not provided for a specific message) by assigning to `MessageRegistry::$defaultLocale`.

```
