V8 API Custom Controllers and Services

Hi Guys,

Apologies if this topic has been covered before, but I haven’t seen any solutions or documentation that helps so far.

I’m in the middle of implementing a customised version of the CRM for my current company and we have a need to allow another of our applications to pull an export of data via the V8 API.

I followed the guidelines, setting up a custom root that shows Hello World quite happily from the documentation and decided to delve a bit further.

I have everything working correctly from the viewpoint of accessing things from Postman and getting a token etc, but I am stuck when I try to create a new Controller.

I thought I would use the UserController and UserService as a model for returning data with the UserController having a single public function.

But with routes.php, services.php and controllers.php all setup I’m getting an error like this in the results from calling my function at localhost/Api/V8/custom/hap

<h1>Slim Application Error</h1>
	<p>The application could not run because of the following error:</p>
	<div><strong>Type:</strong> Error</div>
	<div><strong>Message:</strong> Class 'Api\V8\Controller\HapController' not found</div>
	<div><strong>File:</strong> /Users/michael/Documents/WebDev/HYGH
	<div><strong>Line:</strong> 10</div>

routes.php in custom/application/Ext/Api/V8/Config looks like this:

$app->get('/hap', 'Api\V8\Controller\HapController:getHapExport');

And whatever I use whether I put just HapController or the path it still fails.

controllers.php at custom/application/Ext/Api/V8 looks like this:


    namespace Api\V8;

    use Psr\Container\ContainerInterface as Container;
    use Api\V8\Service\HapService;

    return [
        Controller\HapController::class => function (Container $container) {
            return new Controller\HapController(

services.php at custom/application/Ext/Api/V8 looks like this:


use Api\V8\BeanDecorator\BeanManager;
use Psr\Container\ContainerInterface as Container;
use Api\V8\JsonApi\Helper\AttributeObjectHelper;
use Api\V8\JsonApi\Helper\RelationshipObjectHelper;

return ['hapService' => function (Container $container) {
    return new Api\V8\Service\HapService(

And I have both a HapController.php and HapService.php at custom/application/Ext/Api/V8/Controller and custom/application/Ext/Api/V8/Service respectively.

And both are modeled off the UserController and UserService with the names changed as appropriate.

I’m banging my head against a wall on this and have spent several days trying to fiddle with it but with no result…

Anyone have any ideas? Any help would be very much appreciated! :slight_smile:


This is a long thing to discuss to make custom V8 api enabled. You can engage any experienced developer to do it for you.


Luckily I just figured it out.

I was using the updated composer.json given in the example and that was causing the problem in the end.

I rolled back to the default, added in my custom endpoint and everything is working.

I actually spoke to a very experienced SuiteCRM developer I have just employed to work on the project and he has no experienc of the V8 API either. Seems everyone is using 4.1 instead and the lack of documentation doesn’t help.

I’ve been working in PHP for almost 20 years so I’m fairly experienced myself, but little things like this always slip by especially if you are flying blind with no documentation.

Once I’ve completed the whole endpoint, controllers etc I’ll put up a tutorial in case it helps anyone else.


@BusyBerlinBear thanks for offering to document, that is what is missing!

Our Docs are wiki-like, anyone can edit:

Yes yes, Please share it with community. Actually i have also done it. But it took many days to implement V8 API and that was time taken.

Is there any update in this case, new document help or other guide?, I’m getting the same error that you indicated but I don’t know what changes did you made on the composer.json in order to load custom/application/Ext/Api/V8/Controller and custom/application/Ext/Api/V8/Service respectively.

if you are familiar with composor.json file. He has just used the OLD composor.json file to fetch the dependencies.

Would you be able to elaborate a little more on the composer.json? By old do you mean a version from a fresh install?

@BusyBerlinBear, hi sir were did you put the Controller? Because I got this error bellow
I put my controller at custom/application/Ext/Api/V8/Controller.