PHPackages                             mover-io/belt - 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. mover-io/belt

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

mover-io/belt
=============

A utility belt

v2.0.1(9y ago)566.2k↓19.5%[1 issues](https://github.com/mover-io/belt/issues)2MITPHP

Since Sep 19Pushed 7y ago9 watchersCompare

[ Source](https://github.com/mover-io/belt)[ Packagist](https://packagist.org/packages/mover-io/belt)[ RSS](/packages/mover-io-belt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (13)Used By (2)

belt
====

[](#belt)

---

A PHP developer toolbelt full of rainbows and awesome output!

Created with love by [@jacobstr](https://github.com/jacobstr) and tried and trusted at [@mover](https://github.com/mover-io).

### Classes

[](#classes)

#### Trace

[](#trace)

Provides Error, Logging, and CLI debugging tools through intelligent and colorized stack, source, and result formatted outputs. Better than straight up error\_log because:

1. You always know the line number where the log statement took place, so it's easier to remove later.
2. With a larger traceDepth, you can identity the call sites of your code.
3. The tinting options help during console-debugging sessions that escalate to the stage that you're dumping a lot of data and need a way to visually scan for particular messages.

Example:

```
Belt\Trace::debug($your_result);
// with Stack Trace
Belt\Trace::traceDepth(7)->debug($your_result);
```

#### Text

[](#text)

Provides string format helpers for frequent string helpers.

Example:

```
$route = Belt\Text::ensureNoPrefix($route, "/v2/");
$route = Belt\Text::ensureNoSuffix($route, "/");
```

#### Arrays

[](#arrays)

Provides array helpers for common actions.

Example:

```
// Safe getter that returns null if no value for key
$value = Belt\Array::get($array, 'key', null)
```

#### Profile

[](#profile)

Provides run time profiling for memory and execution time on function calls.

#### SchemaObject

[](#schemaobject)

Facebook's React has a similar concept, known as a *shape*. `SchemaObject` is useful when you want to wrap a plain old array with a type. This in turn, is useful when you want to type hint a function. Instead of declaring a `$user_info` parameter, you can specify `UserInfo $user_info`. Cross-referencing `UserInfo` immediately tells you the key/value pairs that your object should have. Further, the SchemaObject may assist in validation so that the values corresponding to a given key have the correct type.

```
