2017 © Pedro Peláez
 

library l4-to-string

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

image

xethron/l4-to-string

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

  • Wednesday, February 5, 2014
  • by Xethron
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11,260 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

L4ToString

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

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

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!, (*3)

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

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)., (*5)

This means that you will never get an email with an array 3000 lines long as you would with print_r., (*6)

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

I recommend adding a global function to one of your startup files for easier access:, (*8)

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

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., (*9)

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

Two functions are available:

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

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

Query Log to String

This will convert the Laravel 4 Query Log to a neat Query String like:, (*13)

#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:

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, (*14)

License

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

The Versions

05/02 2014

dev-master

9999999-dev http://github.com/Xethron/l4-to-string

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

  Sources   Download

GPL v3

The Requires

 

by Bernhard Breytenbach

convert string print_r

02/02 2014

1.0.2

1.0.2.0 http://github.com/Xethron/l4-to-string

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

  Sources   Download

GPL v3

The Requires

 

by Bernhard Breytenbach

convert string print_r

02/02 2014

1.0.1

1.0.1.0 http://github.com/Xethron/l4-to-string

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

  Sources   Download

GPL v3

The Requires

 

by Bernhard Breytenbach

convert string print_r

01/02 2014

1.0.0

1.0.0.0 http://github.com/Xethron/l4-to-string

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

  Sources   Download

GPL v3

The Requires

 

by Bernhard Breytenbach

convert string print_r