- Edited
Hello TastyIgniter Community,
I’m currently developing a custom API extension for TastyIgniter, and I’ve encountered an issue where my custom API endpoint is not accessible through the standard /api/
path. I followed the documentation to create a simple test endpoint, but when I try to access it, I receive a “Page not found” error. I am allready using the API for my order approver app and it works fantastic. Only the new Test Endpoint is not working
Here’s what I did:
Created the Custom Extension:
I set up the extension structure as follows:
/extensions/myvendor/apiresources/ ├── Extension.php └── ApiResources/ ├── Orders.php └── TestController.php
Registered the API Resource:
I run this command in ssh: php artisan create:apiresource MyVendor.ApiResources Orders
InExtension.php
, I registered a new API resource:<?php namespace MyVendor\ApiResources; use System\Classes\BaseExtension; class Extension extends BaseExtension { public function extensionMeta() { return [ 'name' => 'ApiResources', 'author' => 'MyVendor', 'description' => 'An extension to provide API resources.', 'version' => '1.0.0', 'icon' => 'fa-plug', ]; } public function registerApiResources() { return [ 'test' => [ 'name' => 'Test Route', 'description' => 'A test route to verify API routing', 'controller' => \MyVendor\ApiResources\ApiResources\TestController::class, 'requiredAbilities' => ['orders.read'], ], ]; } }
Test Controller:
I created a simple controller to return a test message:<?php namespace MyVendor\ApiResources\ApiResources; use Igniter\Api\Classes\ApiController; class TestController extends ApiController { public function index() { return $this->asJson(['message' => 'API is working!']); } }
Testing the Endpoint:
When I try to accesshttps://mywebsite.com/api/test
with curl via ssh, I receive a “Page not found” error instead of the expected JSON response. When I try to use endpoint in my app, I also get this error.
What I’ve Checked:
- The extension is enabled.
- The logs do not indicate any permission issues or errors related to this API endpoint.
Has anyone encountered a similar issue or could provide insight into what might be going wrong? Any help or guidance would be greatly appreciated!
Thank you!