wangningkai/var-dumper

基于symfony/var-dumper输出助手函数

dev-master 2018-08-02 03:30 UTC

This package is auto-updated.

Last update: 2024-12-17 21:09:57 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

安装方法 :

composer require wangningkai/var-dumper

使用方法:

可以参考目录下的 heplers/functions.php 内容

<?php

use WangNingkai\VarDumper\Dumper;

if (! function_exists('dd')) {
    /**
     * Dump the passed variables and end the script.
     *
     * @param  mixed
     * @return void
     */
    function dd($args)
    {
        foreach ($args as $var) {
            (new Dumper)->dump($var);
        }
        die(1);
    }
}

if (! function_exists('dda')) {
    /**
     * Dump the passed array variables and end the script.
     *
     * @param  mixed
     * @return void
     */
    function dda($args)
    {
        foreach ($args as $var) {
            (new Dumper)->dump($var->toArray());
        }
        die(1);
    }
}

将其加入到项目的全局函数中去

在其他文件中可以参考下面

<?php

require __DIR__.'/vendor/autoload.php';


$var = array(

    'a simple string' => 'in an array of 5 elements',

    'a float' => 1.0,

    'an integer' => 1,

    'a boolean' => true,

    'an empty array' => array(),

);

dd($var);