在Code Igniter Rest服务器上加载语言时出错

Gui*_*lho 2 php api rest codeigniter

我正在使用Code Igniter编写API,并接受了很多人的建议来使用Code Igniter Rest Server库(Git Repo)。我已经按照开发人员指示的步骤进行操作,但是我遇到了与语言加载有关的问题。据我所知,问题出在我需要REST_Controller.php文件时,并且在某些时候该脚本尝试加载语言文件并失败。问题是我将这个确切的文件放在了应用程序和系统语言/英语目录中。在config.php中,我在语言会话中具有以下内容:

$config['language'] = 'english';
Run Code Online (Sandbox Code Playgroud)

这些是应用程序和系统的语言路径:

应用程序/语言/英语/rest_controller_lang.php
系统/语言/英语/rest_controller_lang.php

而且我仍然收到此错误:

无法加载请求的语言文件:language / english / rest_controller_lang.php

感谢有关如何解决此问题的任何技巧。

Pau*_*mpó 5

我有同样的问题并解决了。

问题是codeigniter找不到rest_controller转换。您只需要创建此文件/application/languages/english/rest_controller_lang.php

然后将此代码复制并粘贴到内部:

<?php
/*
 * English language
 */
$lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Invalid credentials';
$lang['text_rest_ip_denied'] = 'IP denied';
$lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
$lang['text_rest_unauthorized'] = 'Unauthorized';
$lang['text_rest_ajax_only'] = 'Only AJAX requests are allowed';
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
$lang['text_rest_ip_address_time_limit'] = 'This IP Address has reached the time limit for this method';
$lang['text_rest_unknown_method'] = 'Unknown method';
$lang['text_rest_unsupported'] = 'Unsupported protocol';
Run Code Online (Sandbox Code Playgroud)

原始存储库:https : //github.com/chriskacerguis/codeigniter-restserver/blob/master/application/language/english/rest_controller_lang.php

如果您使用的是Linux服务器,则可以使用wget命令和git这样的行视图直接获取它,

wget https://raw.githubusercontent.com/chriskacerguis/codeigniter-restserver/master/application/language/english/rest_controller_lang.php
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你