![]() |
I'm builing 2 controllers
Let's say Project entity One controller will handle the CRUD, Views, etc. app\Controllers\Projects.php PHP Code: <?php The other, will handle the API REST Resources app\Controllers\api\Project.php PHP Code: <?php app\Config\Routes.php Code: $routes->get('/projects', 'Projects::index'); When I call the api route with Browser or Postman, I get ErrorException #64 Cannot declare class App\Controllers\Project, because the name is already in use in D:\www\test\app\Controllers\api\Project.php on line 0 I don't understand it because classNames differ in both Controllers. Any clues? Maybe routes is bad configured? Thanks for any suggestion
Enrique
https://beza.com.ar
The namespace in app\Controllers\api\Project.php is not correct.
PHP Code: namespace App\Controllers; PHP Code: namespace App\Controllers\api; But the file path should be app\Controllers\Api\Project.php, and the namespace also should be App\Controllers\Api, if you follow the naming convention. |
Welcome Guest, Not a member yet? Register Sign In |