Getting 404 error for Action file


I have taken over a project started by someone else. I am trying to extend his Slim application.
by adding another route.
When I try to use the new Action I get in the browser javascript console. 404 (Not Found)

Below is what I did. Any suggestions would be helpful.

The index.php file:

if (PHP_SAPI === ‘cli-server’ && $_SERVER[‘SCRIPT_FILENAME’] !== FILE) { return false;}
require DIR . ‘/…/vendor/autoload.php’;
// Instantiate the app
$settings = require DIR . ‘/…/app/settings.php’;
$app = new \Slim\App($settings);
// Set up dependencies
require DIR . ‘/…/app/dependencies.php’;
// Register middleware
require DIR . ‘/…/app/middleware.php’;
// Register routes
require DIR . ‘/…/app/routes.php’;
// Run!

The file dependencies.php had a section
with several lines like
$container[App\Action\FindPeopleAction::class] = function ($c) {
return new App\Action\FindPeopleAction($c->get(‘logger’));
so I added a new line with
$container[App\Action\GetAnswerAction::class] = function ($c) {
return new App\Action\GetAnswerAction($c->get(‘logger’));

and in routes.php there are lines like:
$app->post(’/findPeople’, App\Action\FindPeopleAction::class)
so added a new line with:
$app->post(’/qetAnswer’, App\Action\GetAnswerAction::class)

In the directory
I placed the file
similar to a file that was already there

In my calling program, I first tested the ajax call using findPeople.
It worked.
But when I changed it to getAnswer I got the 404 error.

Any reason my ajax call is not finding the Action file?


the Q should be a G:

$app->post(’/qetAnswer’, App\Action\GetAnswerAction::class)->setName(‘getAnswer’); // incorrect
$app->post(’/getAnswer’, App\Action\GetAnswerAction::class)->setName(‘getAnswer’); // corrected


Thanks. I will blame that typo on my bifocals.

I changed the q to a g and ran another test but now I get a 500 (Internal Server Error).

Anything else I should try?


Your server log should give you the details of the 500 error.


Thanks. I will check that out.


Again thanks for your help.

In case anyone was wondering if I solved my problem.

The final step to get it to work was fixing an error in the Action file.

When I converted FindPeopleAction.php to getAnswer.php

I did not change

final class FindPeopleAction{

Once I changed it to:
final class GetAnswerAction{

everything worked.

Case Closed.