<?php
// custom/application/Ext/Api/V8/Config/routes.php
$app->get('/hello', function ($request, $response) {
return $response->withJson(['message' => 'Hello from Custom API']);
});
The SuiteCRM V8 API uses a Manual Extension pattern. Unlike other areas of the system, it does not compile fragments from the custom/Extension/ directory. Instead, the CustomLoader looks for specific files directly within the custom/application/Ext/Api/V8/ directory.
To add new endpoints, you must create a routes.php file. All routes defined here are automatically prefixed with the /custom/ namespace.
custom/application/Ext/Api/V8/Config/routes.php
<?php
// custom/application/Ext/Api/V8/Config/routes.php
$app->get('/hello', function ($request, $response) {
return $response->withJson(['message' => 'Hello from Custom API']);
});
Your custom route will be accessible at:
{{suitecrm.url}}/Api/V8/custom/hello
Because the API does not use the standard auto-compilation, controllers must be manually registered in the Dependency Injection (DI) container.
Place your logic in: custom/application/Ext/Api/V8/Controllers/MyCustomController.php
controllers.php Create the file: custom/application/Ext/Api/V8/controllers.php
<?php
use Psr\Container\ContainerInterface as Container;
return [
'MyCustomController' => function (Container $container) {
return new \Custom\Api\V8\Controllers\MyCustomController();
},
];
The CustomLoader only recognizes the following specific filenames. Any other files in these directories will be ignored.
| Filename | Purpose |
|---|---|
|
Define custom Slim routes. |
|
Register custom services in the DI container. |
|
Register custom controllers. |
|
Add custom Slim middlewares. |
|
Override core Slim framework settings. |
File Location: Ensure files are placed directly in custom/application/Ext/Api/V8/ and NOT in custom/Extension/. The API loader will not find files in the Extension folder.
Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.