PHP code example of decodelabs / veneer

1. Go to this page and download the library: Download decodelabs/veneer 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 / veneer example snippets


namespace Some\Random\Library
{
    // This is a library class you use regularly
    class MyThing {
        public function doAThing() {
            echo 'Done!';
        }
    }
}

namespace App\Setup
{
    // This is your environment setup code
    use DecodeLabs\Veneer;
    use Some\Random\Library\MyThing;
    use App\CoolThing;

    Veneer::register(
        MyThing::class, // active object class
        MyThingFrontage::class // frontage class
    );
}

namespace Some\Other\Code
{
    use App\CoolThing;

    // Your general userland code
    CoolThing::doAThing();
}

namespace My\Library
{
    use DecodeLabs\Veneer\Plugin;
    use DecodeLabs\Veneer\LazyLoad;

    class MyThing {

        #[Plugin]
        #[LazyLoad]
        public MyPlugin $plugin;
    }


    class MyPlugin
    {
        public function doAThing(): string {
            return 'Hello from plugin1';
        }
    }
}

namespace Some\Other\Code
{
    use My\Library\MyThing;

    MyThing::$plugin->doAThing(); // Hello from plugin1
}