CodeIgniter Forums
[SOLVED] RESTFul routes with resource not found - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: [SOLVED] RESTFul routes with resource not found (/showthread.php?tid=88172)



[SOLVED] RESTFul routes with resource not found - superior - 08-02-2023

Hi,

I'm currently creating a new RESTfull endpoint for relations, but something seems to be going wrong and i've got no idea if this is something on my end.

Package information
  1. CodeIgniter4 (latest)
  2. Shield (latest)
  3. DayCry Cronjob (latest)

Using the following from the documentation: https://codeigniter4.github.io/userguide/incoming/restful.html#change-the-controller-used

But on the endpoint the following error occurres, and i'm 1000% shure the file is there.
Manually this is no problem, but this requires each endpoint to be set in the routes.

Error: "message": "Controller or its method is not found: \\App\\Outhands\\Relations\\Controllers\\API\\RelationResource::new",

Partial code:
PHP Code:
$routes->group('api/v1', ['filter' => 'tokens'], function($routes) {
    // Relations
    $routes->resource('relations', ['controller' => 'App\Outhands\Relations\Controllers\API\RelationResource''placeholder' => '(:num)']);
    // $routes->get('relations', [RelationResource::class, 'index']);
    // $routes->get('relations/new', [RelationResource::class, 'new']);
    // $routes->get('relations/(:num)', [[RelationResource::class, 'show'], '$1']);
    // $routes->get('relations/(:num)/edit', [[RelationResource::class, 'edit'], '$1']);
    // $routes->post('relations', [RelationResource::class, 'create']);
    // $routes->put('relations/(:num)', [[RelationResource::class, 'update'], '$1']);
    // $routes->delete('relations/(:num)', [[RelationResource::class, 'delete'], '$1']);
}); 

[Image: pfTepPXrjSxZ2hF_1690970040.png]

Did i misunderstood the documentation or does this seem to be a bug in CI4?

update
Apparently i've misspelled the controller, my issue has been resolved.


RE: RESTFul routes with resource not found - InsiteFX - 08-02-2023

Please add [SOLVED] to the Title of this post.
Thank you.


RE: RESTFul routes with resource not found - superior - 08-03-2023

(08-02-2023, 10:52 PM)InsiteFX Wrote: Please add [SOLVED] to the Title of this post.
Thank you.

I'm sorry, the "mark as solved" button is confusing, this only adds a check icon but not the actual tag.
Changed the topic to mark this as resolved, thank you!


RE: [SOLVED] RESTFul routes with resource not found - InsiteFX - 08-03-2023

No Problem.