PHP code example of ray / web-query

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

    

ray / web-query example snippets



use Ray\MediaQuery\Annotation\WebQuery;

interface ApiInterface
{
    #[WebQuery('api.get')]
    public function get(string $id): array;
}


use Ray\MediaQuery\MediaQueryWebModule;
use Ray\MediaQuery\WebQueryConfig;
use Ray\Di\Injector;

$webConfig = new WebQueryConfig('web_query.json', ['domain' => 'example.com']);
$module = new MediaQueryWebModule($webConfig);
$injector = new Injector($module);

$api = $injector->getInstance(ApiInterface::class);
$result = $api->get('123'); // GET https://api.example.com/users/123