PHP code example of decodelabs / glitch

1. Go to this page and download the library: Download decodelabs/glitch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

decodelabs / glitch example snippets


use DecodeLabs\Glitch;

Glitch::getRunMode();
Glitch::dump('hello');

use DecodeLabs\Glitch;

Glitch::registerAsErrorHandler();

use DecodeLabs\Glitch;

Glitch::registerPathAlias('app', '/path/to/my/app');

/*
/path/to/my/app/models/MyModel.php

becomes

app://models/MyModel.php
*/

use DecodeLabs\Glitch;

Glitch::setStartTime(microtime(true));

use DecodeLabs\Glitch;

Glitch::setRunMode('development');

use DecodeLabs\Glitch;

class MyThing {}
$myObject = new MyThing();

// This will dump the object and carry on
dump($myObject);

// This will dump the object and exit
dd($myObject);

use DecodeLabs\Glitch;

function myFunction() {
    // This will throw a Glitch exception
    Glitch::incomplete([
        'info' => 'some test info'
    ]);
}

use DecodeLabs\Glitch;

Glitch::getRenderer()->setCustomCssFile('path/to/my/file.css');

use DecodeLabs\Glitch;

use DecodeLabs\Glitch\Dumpable;

class MyClass implements Dumpable {

    public $myValue = 'Some text';

    private $otherObject;

    protected $arrayValues = [
        'row1' => [1, 2, 3]
    ];

    public function glitchDump(): iterable {
        yield 'text' => $this->myValue;

        // !private, *protected
        yield 'property:!otherObject' => $this->otherObject;

        yield 'values' => $this->arrayValues;
    }
}