I am new to codeigniter and have an old project I am trying to run locally on my MAMP server. I am running into an issue where although the backend loads and connects to the database, the controllers are not working.
I am using MAMP nginx php v7.1.33 and codeigniter v2.1.4.
When I run the application, I get the following error:
<b>Fatal error</b>: Uncaught ArgumentCountError: Too few arguments to function user::index(), 0 passed in /Applications/MAMP/htdocs/dinengo/system/core/CodeIgniter.php on line 359 and exactly 3 expected in /Applications/MAMP/htdocs/dinengo/application/controllers/user.php:109
Stack trace:
#0 /Applications/MAMP/htdocs/dinengo/system/core/CodeIgniter.php(359): user->index()
#1 /Applications/MAMP/htdocs/dinengo/index.php(204): require_once('/Applications/M...')
#2 {main}
thrown in <b>/Applications/MAMP/htdocs/dinengo/application/controllers/user.php</b> on line <b>109</b><br />
the default controller is user and the index for that looks like:
public function index($user_id, $access_token, $employee_id) {
echo 'Authenticating user ';
if ($this->oauth->authenticate($user_id, $access_token)) {
$result = $this->employee_m->getUser($employee_id);
$avatar = $result->avatar;
$pass_image = $result->pass_image;
$base_url = base_url();
$avatar = $base_url . "uploads/avatar/" . $avatar;
$pass_image = $base_url . "uploads/pass/" . $pass_image;
$result->avatar = $avatar;
$result->pass_image = $pass_image;
//echo json_encode($result);
echo '{"success":' . json_encode($result) . '}';
} else {
echo '{"success":' . json_encode("This connection is untrusted") . '}';
}
}
to resolve the above error, I changed that method to:
public function index($user_id=NULL, $access_token=NULL, $employee_id=NULL)
Although that resolved the above issue, When I try to run an api request, I get:
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<center>
<h1>404 Not Found</h1>
</center>
<hr>
<center>nginx/1.25.3</center>
</body>
</html>
I have researched a lot and even tried to change the .hta file thinking its an access issue but had no luck. My current root .htaaccess is:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php (.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
my index.php is:
<?php
ob_start();
define('ENVIRONMENT', 'development');
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
$system_path = 'system';
$application_folder = 'application';
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__ }
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
require_once BASEPATH.'core/CodeIgniter.php';`
my routes.php is:
`$route['default_controller'] = "user";
$route['404_override'] = '';
$route['verify/(:any)'] = "/user/verify/$1";
After fixing the too few arguments error, the application connects successfully but fails any api fails and any route other then to the index.php leads to 404 as shown above.
I have been stuck on this for a while and tried all the treads on this issue I could find with no luck. Thanks in advance for the help.
I managed to fix then 404 issue but am unable to get the api to work.
There are no views associated with this project as it is just for api.
After debugging a bit more, I see that every route other than the base url returns 404. The base url returns 200.

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.