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 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)