1. Go to this page and download the library: Download able/struct 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/ */
able / struct example snippets
use \Able\Struct;
class MyStruct extends AStruct {
protected static $Prototype = ['field1', 'field2'];
}
$Struct = new MyStruct(1,2);
echo $Struct->field1;
//> 1
$Struct = new MyStruct();
$Struct->field1 = "Test string!";
echo $Struct->field1;
//> Test string!
use \Able\Struct;
class MyStruct extends AStruct {
protected static $Prototype = ['field1', 'field2'];
protected final function setField1Property($value) {
return 'The mutated via setter value is: ' . $value;
}
protected final function getField2Property($value) {
return 'The mutated via getter value is: ' . $value;
}
}
$Struct = new MyStruct(1,2);
echo $Struct->field1;
echo $Struct->field2;
//> The mutated via setter value is: 1
//> The mutated via getter value is: 2
$Data = $Struct->toArray();
echo $Data['field1'];
echo $Data['field2'];
//> The mutated via setter value is: 1
//> 2
use \Able\Struct;
class MyParentStruct extends AStruct {
protected static array $Prototype = ['field1', 'field2'];
protected const defaultField1Value = "default value for field1";
protected const defaultField2Value = "default value for field2";
}
use \Able\Struct;
class MyParentStruct extends AStruct {
protected static array $Prototype = ['field1', 'field2'];
}
class MyChildStruct extends MyParentStruct {
protected static array $Prototype = ['field3'];
}