php - Slim api 问题在更新 routes.php 文件后没有响应
问题描述
我对 Slim 框架非常陌生,遇到了非常奇怪的问题。我必须在更新 routes.php 后重新启动我的 apache 才能看到我的更改的效果,因为它停止响应但只有在重新启动 apache 后才能完美运行。
这是我的 routes.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>
解决方案
推荐阅读
- android - 我无法将 Firestore 文档的值分配给类实例
- python - 我可以使用robot.api 获取失败的测试用例名称吗?
- conda - 如何在 conda 包中设置环境变量,以便在激活包含该包的环境时设置它们?
- java - 将字符串数组列表拆分为其原始字符串元素
- python - Scipy solve_ivp vs odeint
- docker - 连接到独立 chrome 调试容器时如何避免身份验证?
- postgresql - 在 postgresql 中查询多个 Jsonb 列
- point - 将边界框[(x1,y1),(x2,y2),(x3,y3),(x4,y4)] 内的点(x,y) 转换为航向
- ruby-on-rails - 如何在 Rails 中生成序列码字符串
- python - 使用python和mobaxterm将25个随机文件从一个文件夹复制到另一个文件夹