1. Go to this page and download the library: Download jorgeanzola/craft-scout 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/ */
// Can be set to a function
'transformer' => function(craft\elements\Entry $entry) {
return [
'title' => $entry->title,
'id' => $entry->id,
'url' => $entry->url,
];
},
// Or a string/array that defines a Transformer class configuration
'transformer' => 'MyTransformerClassName',
// Or a Transformer class instance
'transformer' => new MyTransformerClassName(),
use craft\elements\Entry;
use League\Fractal\TransformerAbstract;
class MyTransformerClassName extends TransformerAbstract
{
public function transform(Entry $entry)
{
return [
// ...
];
}
}