1. Go to this page and download the library: Download chipslays/sauce 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/ */
chipslays / sauce example snippets
use Sauce\Traits\Singleton;
class Hero
{
use Singleton;
}
$hero1 = Hero::getInstance();
$hero1->attack();
Hero::forgetInstance();
$hero2 = Hero::getInstance();
$hero2->attack();
use Sauce\Traits\Singleton;
class SingletonClass {
use Singleton;
private $value;
/**
* @param mixed $value
* @return static
*/
public function set($value)
{
$this->value = $value;
return $this;
}
/**
* @return mixed
*/
public function get()
{
return $this->value;
}
}
echo SingletonClass::getInstance()->set(1)->get(); // return 2
echo SingletonClass::getInstance()->set(2)->get(); // return 2
SingletonClass::forgetInstance();
echo SingletonClass::getInstance()->set(3)->get(); // return 3
use Sauce\Traits\MappableClass;
class MappableClass {
use Mappable;
}
$class = new MappableClass;
$class->map('sum', fn(...$args) => array_sum($args));
echo $class->sum(1000, 300, 30, 5, 2) // 1337
$class::mapOnce('timestamp', fn() => time());
echo $class->timestamp(); // e.g. 1234567890
echo $class->timestamp(); // e.g. 1234567890
use Sauce\Traits\MappableClass;
class MappableClass {
use Mappable;
}
MappableClass::map('sum', fn(...$args) => array_sum($args));
echo MappableClass::sum(1000, 300, 30, 5, 2)
MappableClass::mapOnce('timestamp', fn() => time());
echo MappableClass::timestamp()
use Sauce\Traits\Call;
class MyClass {
use Call;
}
$class = new MyClass;
$class->__call_function(fn () => true);
$class->__call_function('\App\Controllers\MainController@home');
$class->__call_function('\App\Controllers\MainController@users', [$id]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.