PHP code example of der-spiegel / ww-assets-client

1. Go to this page and download the library: Download der-spiegel/ww-assets-client 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/ */

    

der-spiegel / ww-assets-client example snippets


$assetsConfig = AssetsConfig::create(
    'https://assets.example.com/', // Assets URL (without app/ or services/ postfix)
    'username',                    // Assets user name (API user preferred)
    'password'                     // That user's password
);

$assetsClient = new AssetsClient($assetsConfig, $logger); // Create client

$request = new SearchRequest($assetsClient,               // Create search request
        q: '',                                            // Assets query
        metadataToReturn: ['']                            // Metadata fields to return
);

$response = $request();                                   // Perform search

foreach ($response->hits as $assetResponse) {             // Loop through results
    echo $assetResponse->id . "\n";                       // Access asset metadata
}

$ docker run -it --rm --name assets-client-example \
  --volume "$PWD":/usr/src/myapp --workdir /usr/src/myapp \
  php:cli php MyExample.php