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.

https://api.mysite.net/getAnswer 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’;
session_start();
// 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!
$app->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)
->setName(‘findPeople’);
so added a new line with:
$app->post(’/qetAnswer’, App\Action\GetAnswerAction::class)
->setName(‘getAnswer’);


In the directory
app/src/Action
I placed the file
GetAnswerAction.php
similar to a file that was already there
FindPeopleAction.php

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.