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>
<h2>Details</h2>
<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
Projects/HYGH-Spot-CRM/custom/application/Ext/Api/V8/controllers.php</div>
<div><strong>Line:</strong> 10</div>
routes.php in custom/application/Ext/Api/V8/Config looks like this:
<?php
$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:
<?php
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(
$container->get(HapService::class)
);
}
];
services.php at custom/application/Ext/Api/V8 looks like this:
<?php
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(
$container->get(BeanManager::class),
$container->get(AttributeObjectHelper::class),
$container->get(RelationshipObjectHelper::class)
);
}];
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!