PHP code example of cable / cable-annotations

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

    

cable / cable-annotations example snippets



use Cable\Annotation\Factory;


$annotation = Factory::create();


/**
 *
 * @Name("Test") the name of command
 *
 */
class TestCommand extends Command{


     /**
      *
      * @Annotation() // you must add this 
      *                // if you want to use that property
      *
      * @Required() // if this parameter not given by user, 
      *              //will be thrown a exception
      *
      * @Default('Default value'); // default value of property
      *                             // if you set this, 
 


class Test{


      /**
       * 
       * @Test(name = "test name")
       *
       *
       */
      public function testing(){
      
      }

}

// execute the class instance
$class = $annotation->executeClass(new Test());

$methods = $annotation->methods();
// $annotation->get('methods') // same as above


// $methods->get('Test');
foreach($methods->Test() as $test){
    echo $test->name; // test name will be printed
}



    /**
     *
     * @Test(datas={test: "test"})
     *
     * will be given as ["test" = "test"]
     *
     */


      /**
       *
       * @Test(data= @Test(name = "data"))
       *
       *
       * // you can give @Test  into data
       */


Annotation::setContainer($container);

``