{"id":1884,"date":"2020-05-20T00:00:00","date_gmt":"2020-05-19T22:00:00","guid":{"rendered":"https:\/\/wwwneu.strehle.de\/tim\/weblog\/archives\/2020\/05\/20\/1643-2\/"},"modified":"2025-07-31T21:35:56","modified_gmt":"2025-07-31T19:35:56","slug":"1643-2","status":"publish","type":"post","link":"https:\/\/www.strehle.de\/tim\/weblog\/archives\/2020\/05\/20\/1643-2\/","title":{"rendered":"Open source PHP client for the WoodWing Assets (Elvis) REST API"},"content":{"rendered":"\n<p>In my role as \u201cProject Manager for DAM systems\u201d at the <a href=\"https:\/\/www.spiegelgruppe.de\">SPIEGEL-Verlag<\/a>, I spent the last year helping to roll out the <a href=\"https:\/\/www.woodwing.com\/en\/digital-asset-management-system\">WoodWing Assets<\/a> (formerly known as \u201cElvis\u201d) DAM software. It\u2019s not used for the print publication yet (as this <a href=\"https:\/\/www.woodwing.com\/en\/press\/10-10-2018\/spiegel-group-improves-user-experience-and-modernizes-image-workflows-with-the-help\">premature press release<\/a> suggests), but it powers most of the photos published on <a href=\"https:\/\/www.spiegel.de\/\">spiegel.de<\/a> since the <a href=\"https:\/\/medium.com\/@devspiegel\/alles-neu-denken-der-prozess-hinter-dem-relaunch-des-digitalen-spiegel-331e76255e48\">January relaunch<\/a>.<\/p>\n\n\n\n<p>We decided to open-source the Assets plugins and integrations we and our development partners built during this project \u2013 where it makes sense, and as our time permits.<\/p>\n\n\n\n<p>The first open source code we\u2019re publishing is this PHP client library for the <a href=\"https:\/\/helpcenter.woodwing.com\/hc\/en-us\/sections\/360000141063-API-REST\">Assets REST API<\/a>:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/DerSpiegel\/ww_elvis_php_client\">DerSpiegel \/ ww_elvis_php_client on Github<\/a><\/p>\n\n\n\n<p>Documentation and tests are still missing, but the library is stable (we\u2019re using this code in production). It is pretty lightweight and can be used for one-off batch scripts.<\/p>\n\n\n\n<p>If you have <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\">Docker Desktop<\/a> installed, it\u2019s easy to get started \u2013 you don\u2019t need a server, virtual machine, or PHP runtime. This Docker \/ Composer command fetches the library and all its dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run --rm --interactive --tty \\\n  --volume $PWD:\/app \\\n  --volume ${COMPOSER_HOME:-$HOME\/.composer}:\/tmp \\\n  composer require der-spiegel\/ww-elvis-client monolog\/monolog\n<\/code><\/pre>\n\n\n\n<p>Create your first script by copying the provided example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cp vendor\/der-spiegel\/ww-elvis-client\/UsageExample.php MyExample.php\n<\/code><\/pre>\n\n\n\n<p>Edit your copy, setting the correct Assets URL, username (API user preferred) and password in this section:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$elvisConfig = new ElvisConfig(\n    'https:\/\/assets.example.com\/', \/\/ Assets URL (without app\/ postfix)\n    'username',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Assets user name (API user preferred)\n    'password'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ That user's password\n);\n<\/code><\/pre>\n\n\n\n<p>The example script performs a simple search across all Elvis assets (visible for that user) and returns the first 50 asset IDs \u2013 you can leave it as is for a first test:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$elvisClient = new ElvisClient($elvisConfig, $logger); \/\/ Create client\n\n$request = (new SearchRequest($elvisConfig))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Create search request\n    -&gt;setQ('')&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Assets query\n    -&gt;setMetadataToReturn(&#91;'']);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Metadata fields to return\n    \n$response = $elvisClient-&gt;search($request);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Perform search\n\nforeach ($response-&gt;getHits() as $assetResponse) {&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Loop through results\n    echo $assetResponse-&gt;getId() . \"\\n\";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ Access asset metadata\n}\n<\/code><\/pre>\n\n\n\n<p>Finally, run your script via Docker:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker run -it --rm --name ww-elvis-client-example \\\n  --volume \"$PWD\":\/usr\/src\/myapp --workdir \/usr\/src\/myapp \\\n  php:7.4-cli php MyExample.php\n<\/code><\/pre>\n\n\n\n<p>It should display a list of the first 50 asset IDs.<\/p>\n\n\n\n<p>I hope this library is useful to other WoodWing customers. Let me know if you have questions or need help using it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my role as \u201cProject Manager for DAM systems\u201d at the SPIEGEL-Verlag, I spent the last year helping to roll out the WoodWing Assets (formerly known as \u201cElvis\u201d) DAM software. It\u2019s not used for the print publication yet (as this premature press release suggests), but it powers most of the photos published on spiegel.de since [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_share_on_mastodon":"0"},"categories":[1],"tags":[],"class_list":["post-1884","post","type-post","status-publish","format-standard","hentry","category-weblog"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/posts\/1884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/comments?post=1884"}],"version-history":[{"count":1,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/posts\/1884\/revisions"}],"predecessor-version":[{"id":1890,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/posts\/1884\/revisions\/1890"}],"wp:attachment":[{"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/media?parent=1884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/categories?post=1884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strehle.de\/tim\/wp-json\/wp\/v2\/tags?post=1884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}