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?