PHP code example of gamernetwork / yolk-core

1. Go to this page and download the library: Download gamernetwork/yolk-core 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/ */

    

gamernetwork / yolk-core example snippets


use yolk\Yolk;

// Using a closure
Yolk::run(function() {
  echo "Hello World";
});

// Using a function name
function hello() {
  echo "Hello World";
}
Yolk::run('hello');

// Using an object...
class Foo {
  public static function hello() {
    echo "Hello World";
  }
  public function helloWorld() {
    echo "Hello World";
  }
  public function __invoke() {
    $this->helloWorld();
  }
}

// ...static callback
Yolk::run(['Foo', 'hello']);

// ...instance callback
$o = new Foo();
Yolk::run([$o, 'hello']);

// ...invokable object
Yolk::run($o);

use yolk\Yolk;

Yolk::setErrorHandler($callback);

Yolk::setExceptionHandler($callback);

use yolk\Yolk;

// enabled/disable debug flag
Yolk::setDebug(true);

// Return current setting of debug flag
Yolk::isDebug();

use yolk\Yolk;

Yolk::setErrorPage($path_to_file);

use yolk\Yolk;

/**
 * $var - any variable or constant
 * $format - one of null, Yolk::DUMP_TEXT, Yolk::DUMP_HTML, Yolk::DUMP_TERMINAL
 */
Yolk::dump($var, $format = null);

use yolk\Yolk;

class MyHelper {
  public static function foo() {
    echo 'foo';
  }
  public static function bar() {
    echo 'bar';
  }
}

Yolk::registerHelper('\\MyHelper');

Yolk::foo();
Yolk::bar();