gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

README.md (2878B)


      1 Exporter
      2 ========
      3 
      4 [![Build Status](https://secure.travis-ci.org/sebastianbergmann/exporter.png?branch=master)](https://travis-ci.org/sebastianbergmann/exporter)
      5 
      6 This component provides the functionality to export PHP variables for visualization.
      7 
      8 ## Usage
      9 
     10 Exporting:
     11 
     12 ```php
     13 <?php
     14 use SebastianBergmann\Exporter\Exporter;
     15 
     16 $exporter = new Exporter;
     17 
     18 /*
     19 Exception Object &0000000078de0f0d000000002003a261 (
     20     'message' => ''
     21     'string' => ''
     22     'code' => 0
     23     'file' => '/home/sebastianbergmann/test.php'
     24     'line' => 34
     25     'trace' => Array &0 ()
     26     'previous' => null
     27 )
     28 */
     29 
     30 print $exporter->export(new Exception);
     31 ```
     32 
     33 ## Data Types
     34 
     35 Exporting simple types:
     36 
     37 ```php
     38 <?php
     39 use SebastianBergmann\Exporter\Exporter;
     40 
     41 $exporter = new Exporter;
     42 
     43 // 46
     44 print $exporter->export(46);
     45 
     46 // 4.0
     47 print $exporter->export(4.0);
     48 
     49 // 'hello, world!'
     50 print $exporter->export('hello, world!');
     51 
     52 // false
     53 print $exporter->export(false);
     54 
     55 // NAN
     56 print $exporter->export(acos(8));
     57 
     58 // -INF
     59 print $exporter->export(log(0));
     60 
     61 // null
     62 print $exporter->export(null);
     63 
     64 // resource(13) of type (stream)
     65 print $exporter->export(fopen('php://stderr', 'w'));
     66 
     67 // Binary String: 0x000102030405
     68 print $exporter->export(chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5));
     69 ```
     70 
     71 Exporting complex types:
     72 
     73 ```php
     74 <?php
     75 use SebastianBergmann\Exporter\Exporter;
     76 
     77 $exporter = new Exporter;
     78 
     79 /*
     80 Array &0 (
     81     0 => Array &1 (
     82         0 => 1
     83         1 => 2
     84         2 => 3
     85     )
     86     1 => Array &2 (
     87         0 => ''
     88         1 => 0
     89         2 => false
     90     )
     91 )
     92 */
     93 
     94 print $exporter->export(array(array(1,2,3), array("",0,FALSE)));
     95 
     96 /*
     97 Array &0 (
     98     'self' => Array &1 (
     99         'self' => Array &1
    100     )
    101 )
    102 */
    103 
    104 $array = array();
    105 $array['self'] = &$array;
    106 print $exporter->export($array);
    107 
    108 /*
    109 stdClass Object &0000000003a66dcc0000000025e723e2 (
    110     'self' => stdClass Object &0000000003a66dcc0000000025e723e2
    111 )
    112 */
    113 
    114 $obj = new stdClass();
    115 $obj->self = $obj;
    116 print $exporter->export($obj);
    117 ```
    118 
    119 Compact exports:
    120 
    121 ```php
    122 <?php
    123 use SebastianBergmann\Exporter\Exporter;
    124 
    125 $exporter = new Exporter;
    126 
    127 // Array ()
    128 print $exporter->shortenedExport(array());
    129 
    130 // Array (...)
    131 print $exporter->shortenedExport(array(1,2,3,4,5));
    132 
    133 // stdClass Object ()
    134 print $exporter->shortenedExport(new stdClass);
    135 
    136 // Exception Object (...)
    137 print $exporter->shortenedExport(new Exception);
    138 
    139 // this\nis\na\nsuper\nlong\nstring\nt...\nspace
    140 print $exporter->shortenedExport(
    141 <<<LONG_STRING
    142 this
    143 is
    144 a
    145 super
    146 long
    147 string
    148 that
    149 wraps
    150 a
    151 lot
    152 and
    153 eats
    154 up
    155 a
    156 lot
    157 of
    158 space
    159 LONG_STRING
    160 );
    161 ```
    162 
    163 ## Installation
    164 
    165 To add Exporter as a local, per-project dependency to your project, simply add a dependency on `sebastian/exporter` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on Exporter 1.0:
    166 
    167     {
    168         "require": {
    169             "sebastian/exporter": "1.0.*"
    170         }
    171     }