PHP code example of hubert / avocado

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

    

hubert / avocado example snippets


class Message {
    public function __construct(private string $message){}
}

#[RestController]
class GrettingController {

    
    // response will be JSON { "message": "Hello, <name>!" }
    #[GetMapping("/gretting/:name")]
    public function greet(#[RequestParam(name: "name", defaulValue: "John")] string $name): Message {
        return new Message("Hello, " . $name . "!");
    }
    
}

#[Avocado]
class DemoApplication {

    public static function run(): void {
        Application::run(__DIR__);
    }
    
}

DemoApplication::run();