PHP code example of ddesrosiers / silex-annotation-provider

1. Go to this page and download the library: Download ddesrosiers/silex-annotation-provider 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/ */

    

ddesrosiers / silex-annotation-provider example snippets


$app->register(new DDesrosiers\SilexAnnotations\AnnotationServiceProvider(), array(
    "annot.cache" => new MyPsr16Cache(),
    "annot.controllerDir" => "$srcDir/Controller",
    "annot.controllers" => [
        MyClass1::class,
        MyClass2::class
    ]
));

namespace DDesrosiers\Controller;

use Symfony\Component\HttpFoundation\Response;

/**
 * @Controller(
 *     prefix => test
 *     after => \DDesrosiers\Controller\TestController::converter
 *     host => www.test.com
 *         after => \DDesrosiers\Controller\TestController::converter
     *     host => www.test.com
     *     

$controllerCollection = $app['controller_factory']
    ->after('\DDesrosiers\Controller\TestController::converter');
    ->host('www.test.com');
    -> ->convert('var', "\\DDesrosiers\\Controller\\TestController::converter");
    ->host('www.test.com')
    ->

   namespace DDesrosiers\Controller;
   
   use Symfony\Component\HttpFoundation\Response;
   
   /**
    * @Controller(test)
    */
   class TestController
   {
       /**
        * @Route(GET test/{var})
        */
       public function testMethod($var)
       {
           return new Response("test Method: $var");
       }
   }