我对Slim框架非常陌生,并且遇到了非常奇怪的问题。 我必须在更新routes.php后重新启动我的apache,以查看更改的效果,因为它停止响应,但仅在重新启动apache之后才能正常工作。
这是我的路线的内容。php-
<pre>
<?php
require 'vendor/autoload.php';
include_once 'Auth.php';
include_once 'common/ReuseFunctions.php';
include_once 'Controllers/CodeController.php';
include_once 'Controllers/UserController.php';
include_once 'Controllers/WebinarController.php';
include_once 'Controllers/NotificationController.php';
include_once 'Controllers/JobsController.php';
include_once 'Controllers/EventsCgController.php';
include_once 'Controllers/NewsController.php';
include_once 'Controllers/CodeContestController.php';
include_once 'Controllers/LeaderboardController.php';
include_once 'Controllers/SkillTestController.php';
include_once 'Controllers/TestController.php';
include_once 'Controllers/ReportController.php';
include_once 'Controllers/QuestionController.php';
include_once 'Controllers/WebinarHireController.php';
include_once 'Controllers/CommunityController.php';
session_start();
use \Firebase\JWT\JWT;
use Slim\Middleware\TokenAuthentication;
use RateLimiter\Middleware as RateLimiterMiddleware;
$configuration = [
'settings' => [
'displayErrorDetails' => false,
],
];
$c = new \Slim\Container($configuration);
$c['session'] = function ($c) {
return new \SlimSession\Helper;
};
$app = new Slim\App($c);
// $app = new Slim\App();
$app->add(new \Slim\Middleware\Session([
'name' => 'dummy_session',
'autorefresh' => true,
'lifetime' => '1 hour'
]));
$authenticator = function($request, TokenAuthentication $tokenAuth){
$token = $tokenAuth->findToken($request);
$auth = new Auth();
$auth->getUserByToken($token);
};
$app->add(new TokenAuthentication([
'path' => ['/user', '/webinar', '/notification', '/jobs', '/skill_test', '/news', '/leaderboard', '/code_contest', '/events_cg', '/test', '/candidate_report', '/question', '/webinar_hire'],
'header' => 'Auth-Token',
'regex' => '/(.*)/',
'authenticator' => $authenticator
]));
$middlware = new RateLimiterMiddleware(['hourly_request_limit' => HOURLY_RATE_LIMIT,
'minute_request_limit' => (new \SlimSession\Helper)->memType,
'second_request_limit' => SECOND_RATE_LIMIT], unserialize(REDIS_SETTINGS));
$app->add($middlware);
// $middlware = new RateLimiterMiddleware(['hourly_request_limit' => HOURLY_RATE_LIMIT,
// 'minute_request_limit' => 15,
// 'second_request_limit' => SECOND_RATE_LIMIT], unserialize(REDIS_SETTINGS));
// $app->add($middlware);
$app->group('/user', function () {
$this->get('/list_all_users', function ($request, $response, $args) {
$result = UserController::list_all_users($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/retrieve_user_by_id', function ($request, $response, $args) {
$result = UserController::retrieve_user_by_id($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/check_email_exists', function ($request, $response, $args) {
$result = UserController::check_email_exists($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/register_without_mobile', function ($request, $response, $args) {
$result = UserController::register_without_mobile($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/reset_password', function ($request, $response, $args) {
$result = UserController::reset_password($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/social_login', function ($request, $response, $args) {
$result = UserController::social_login($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/country_list', function ($request, $response, $args) {
$result = UserController::country_list($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->patch('/update_user_profile', function ($request, $response, $args) {
$result = UserController::update_user_profile($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/auto_suggest', function ($request, $response, $args) {
$result = UserController::auto_suggest($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/logout', function ($request, $response, $args) {
$result = UserController::logout($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/register', function ($request, $response, $args) {
$result = UserController::register($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/login', function ($request, $response, $args) {
$result = UserController::login($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->put('/change_password', function ($request, $response, $args) {
$result = UserController::change_password($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/edit_picture', function ($request, $response, $args) {
$result = UserController::edit_picture($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/city_list', function ($request, $response, $args) {
$result = UserController::city_list($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
});
$app->group('/leaderboard', function () {
$this->get('/leaderboard_list', function ($request, $response, $args) {
$result = LeaderboardController::leaderboard_list($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/challenge_leaderboard', function ($request, $response, $args) {
$result = LeaderboardController::challenge_leaderboard($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
});
$this->get('/popular_skill_test', function ($request, $response, $args) {
$result = SkillTestController::popular_skill_test($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
});
$app->group('/notification', function () {
$this->post('/register_device', function ($request, $response, $args) {
$result = NotificationController::register_device($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/gcm_registration', function ($request, $response, $args) {
$result = NotificationController::gcm_registration($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/notification_settings', function ($request, $response, $args) {
$result = NotificationController::notification_settings($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/update_available', function ($request, $response, $args) {
$result = NotificationController::update_available($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->patch('/update_read_status', function ($request, $response, $args) {
$result = NotificationController::update_read_status($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/past_notifications', function ($request, $response, $args) {
$result = NotificationController::past_notifications($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/app_feedback', function ($request, $response, $args) {
$result = NotificationController::app_feedback($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->get('/get_settings_list', function ($request, $response, $args) {
$result = NotificationController::get_settings_list($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
$this->post('/log_data', function ($request, $response, $args) {
$result = NotificationController::log_data($request, $response, $args);
$response->write($result);
return $response;
// echo $result;
// die;
});
});
$app->run();
?>
</pre>