How do I create an external transformer class when using the ElementApi plugin? I've been trying to clean up my elementapi.php file, and one very important step in making it more DRY is to have reusable transformer classes. 

But I cannot seem to get it to work, the following gives me a blank page. 

So far in my elementapi.php file I have the following.

'api/articles' =&gt; function() {
// I have also tried to place this line at the very top of the file.            
require_once craft()-&gt;path-&gt;getConfigPath().'transformers/EntryInfoTransformer.php';

            'criteria' =&gt; [
                'section' =&gt; 'blog',
                'order' =&gt; 'postDate desc',
            ],

            'elementsPerPage' =&gt; 5,
            'elementType' =&gt; 'Entry',
            'transformer' =&gt; new EntryInfoTransformer(),
        },


and my EntryInfoTransformer.php file has 

&lt;?php

require craft()-&gt;path-&gt;getPluginsPath().'elementapi/vendor/autoload.php';

use League\Fractal\TransformerAbstract;
class EntryInfoTransformer extends TransformerAbstract{
    public function transform(EntryModel $entry) {
        return [
            'id' =&gt; $entry-&gt;id,
        ]
    },
}


I don't get any errors, nothing in either the php or craft logs, just a blank while page. This has been tested on php 5.5 &amp; 5.6. Site runs normally otherwise.
You're getting a whitescreen because you've got some PHP syntax errors in both files. Craft isn't reporting them because those config files get loaded before Craft has had a chance to bootstrap.  The underlying errors should be recorded in your web server's error logs depending on your default server configuration.

Try these:

elementapi.php

&lt;?php
namespace Craft;

require_once craft()-&gt;path-&gt;getConfigPath().'transformers/EntryInfoTransformer.php';

return [
    'endpoints' =&gt; [
        'api/articles' =&gt; function() {
            return [
                'criteria'        =&gt; [
                    'section' =&gt; 'blog',
                    'order'   =&gt; 'postDate desc',
                ],
                'elementsPerPage' =&gt; 5,
                'elementType'     =&gt; 'Entry',
                'transformer'     =&gt; new EntryInfoTransformer(),
            ];
        },
    ]
];


EntryInfoTransformer.php

&lt;?php
namespace Craft;

require craft()-&gt;path-&gt;getPluginsPath().'elementapi/vendor/autoload.php';

use League\Fractal\TransformerAbstract;

class EntryInfoTransformer extends TransformerAbstract
{
    public function transform(EntryModel $entry){
        return [
            'id' =&gt; $entry-&gt;id,
        ];
    }
}