PHPackages                             xethron/l4-to-string - 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. xethron/l4-to-string

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

xethron/l4-to-string
====================

Laravel 4 version of xethron/to-string, which adds query and queryLog to string functions.

1.0.2(12y ago)017.3k1GPL v3PHPPHP &gt;=5.3.0

Since Feb 1Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Xethron/l4-to-string)[ Packagist](https://packagist.org/packages/xethron/l4-to-string)[ Docs](http://github.com/Xethron/l4-to-string)[ RSS](/packages/xethron-l4-to-string/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

L4ToString
==========

[](#l4tostring)

[![Latest Stable Version](https://camo.githubusercontent.com/7fff6b53e490d65ba91201605066c7672237db2ba15e42185883a3849842c4e1/68747470733a2f2f706f7365722e707567782e6f72672f78657468726f6e2f6c342d746f2d737472696e672f762f737461626c652e706e67)](https://packagist.org/packages/xethron/l4-to-string) [![Total Downloads](https://camo.githubusercontent.com/352f4136a6f6b91a3d284bdf096d740fa4c5cbf065a881d1a06dbc69606171b7/68747470733a2f2f706f7365722e707567782e6f72672f78657468726f6e2f6c342d746f2d737472696e672f646f776e6c6f6164732e706e67)](https://packagist.org/packages/xethron/l4-to-string) [![Latest Unstable Version](https://camo.githubusercontent.com/0cb8d9d709b399176545331a1af20636e484c83e38e4dd9cd6c244d1c409a830/68747470733a2f2f706f7365722e707567782e6f72672f78657468726f6e2f6c342d746f2d737472696e672f762f756e737461626c652e706e67)](https://packagist.org/packages/xethron/l4-to-string) [![License](https://camo.githubusercontent.com/a613e6ac582bb0318c0a8662c12714e3a8c79214929768cc9e7a71c7984fd33d/68747470733a2f2f706f7365722e707567782e6f72672f78657468726f6e2f6c342d746f2d737472696e672f6c6963656e73652e706e67)](https://packagist.org/packages/xethron/l4-to-string)

Logging variables can sometimes cause huge logs, especially if you want to email those logs to yourself.

On the other hand, logging exceptions with the default \_\_toString can will most likely give you just enough information to confuse the hell out of you!

This class extends Xethron\\ToString, and in addition, adds a few Laravel 4 specific functions for converting Query Logs to Strings.

Variable to String
==================

[](#variable-to-string)

This is a function that will display a variable similar to print\_r, with the ability to specify the max\_lines, max\_depth (for arrays) and min\_depth (for arrays).

This means that you will never get an email with an array 3000 lines long as you would with print\_r.

`Xethron\L4ToString::variable( $var, $max_lines, $max_depth, $min_depth )`

I recommend adding a global function to one of your startup files for easier access:

```
function varToStr( $var, $max_lines = 10, $max_depth = 4, $min_depth = 2 )
{
    return Xethron\L4ToString::variable( $var, $max_lines, $max_depth, $min_depth );
}
```

Exception to String
===================

[](#exception-to-string)

This converts an Exception to string, much like PHP's \_\_toString, however, it won't cut off those important pieces of information you require while debugging.

On top of that, it also uses the Variable to String to to include all the variables passed in the Stack Trace.

Two functions are available:
----------------------------

[](#two-functions-are-available)

`Xethron\L4ToString::exception( $e ); // This will print out the entire Exception`

`Xethron\L4ToString::trace( $e->getTrace() ); // This will only print out the stack trace`

Query Log to String
===================

[](#query-log-to-string)

This will convert the Laravel 4 Query Log to a neat Query String like:

```
#0 select * from `table` where `table`.`id` = 113 and `deleted` = 0 limit 1;
    {"bindings":[113,0],"time":1.08}
#1 select * from `another_table` where `another_table`.`deleted_at` is null and `id` = '66' limit 1;
	{"bindings":["66"],"time":0.49}
#2 select * from `country` where `country`.`deleted` = 0 and `country`.`name` in ('South Africa');
	{"bindings":[0,"South Africa"],"time":0.51}
```

Two Functions are available:
----------------------------

[](#two-functions-are-available-1)

`Xethron\L4ToString::queryLog(); // gets the latest query log and prints it``Xethron\L4ToString::queryLog( \DB::getQueryLog() ); // Specify your own query log``Xethron\L4ToString::query( $qyery ); // Pass a single query from the query log to be converted to string`

License
=======

[](#license)

L4ToString is distributed under the terms of the GNU General Public License, version 3 or later.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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 ~0 days

Total

3

Last Release

4488d ago

### Community

Maintainers

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

---

Top Contributors

[![Xethron](https://avatars.githubusercontent.com/u/1497338?v=4)](https://github.com/Xethron "Xethron (6 commits)")

---

Tags

convertstringprint\_r

### Embed Badge

![Health badge](/badges/xethron-l4-to-string/health.svg)

```
[![Health](https://phpackages.com/badges/xethron-l4-to-string/health.svg)](https://phpackages.com/packages/xethron-l4-to-string)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[coduo/php-to-string

Simple library that converts PHP value into strings

27112.7M10](/packages/coduo-php-to-string)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)[opis/string

Multibyte strings as objects

7420.9M7](/packages/opis-string)

PHPackages © 2026

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