PHP code example of proteins / extensions

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

    

proteins / extensions example snippets


use Proteins\Extensions;

class Test {
    use Extensions;
}

class Test {
  use Extensions;
  public static function foo(){ echo "Foo!"; }
}

Test::foo(); // Foo!
Test::bar(); // Fatal error: Call to undefined method Test::bar

Test::extend([
  'bar' => function(){ echo "Bar!"; },
]);

Test::bar();  // Bar!