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
namespace App\Controllers;
class Projects extends BaseController
{
public function index()
{
}
}
The other, will handle the API REST Resources
app\Controllers\api\Project.php
PHP Code:
<?php
namespace App\Controllers;
use CodeIgniter\RESTful\ResourceController;
class Project extends ResourceController
{
protected $modelName = '';
protected $format = 'json';
public function index()
{
}
app\Config\Routes.php
Code:
$routes->get('/projects', 'Projects::index');
$routes->resource('/api/project', ['only' => ['index', 'show']]);
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