dongqiao6730 2018-09-29 06:08
浏览 69
已采纳

SLIM错误::在服务器上托管SLIM应用程序时找不到AuthController

I have a REST api app using SLIM framework. Below is my app dir structure enter image description here

Below is structure in my controllers dir

enter image description here

Authcontroller.php is in Auth folder.

Below are namespaces given to ActionController and Authcontroller enter image description here enter image description here

Both controllers (Action and Auth) are defined in container as below in the mainapp enter image description here

Above app is working fine on my localhost ,but when i upload same to my server, it get below error on above line 58 enter image description here

Please help me here , i am going mad,have changed around 3 hosting servers(SHARED-HOSTING),but still same error. PLEASE HELP!!

  • 写回答

1条回答 默认 最新

  • duanquan4451 2018-09-29 08:50
    关注

    If your deployment server is Linux, mostly, because path is case-sensitive.

    If your composer.json contains section such as below

    ...
    "autoload": {
        "psr-4": {
            "App\\": "app"
        },
    },
    ...
    

    Composer PSR-4 autoloading expect to find class

    \App\Controllers\Auth\AuthController
    

    in file

     app\Controllers\Auth\AuthController.php
    

    but it can not find it because yours is

     app\controllers\Auth\AuthController.php
    

    Since your development machine seems to use Windows which by default is case-insensitive,

     app\controllers\Auth\AuthController.php
    

    equals to

     app\Controllers\Auth\AuthController.php
    

    Which is why it works on your development machine but not on deployment server.

    So the solution is to rename any directory/files to match its case and also make sure that all files is copied to deployment server.

    After you change directory/filename case, run

    $ composer dump-autoload

    So new autoload file is generated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里