doupeng2253 2019-08-12 10:19
浏览 116
已采纳

如何在搜索类时让Laravel忽略文件路径?

I'm developing a package for laravel, and some code needs to be completed by the Application developer (to map their models to the models of my package).

I would like to publish some model templates from my package folders to the App folders, in order to facilitate the application developer's job.

But even once the published files are filled accordingly in the App folder (in \app\Integration\myPackageName\Mapping), Laravel tries to use the unfilled files in my Package's folder (\packages\my\package\src\Mapping\Publishables), which obviously results in an error.

Is there a way to get Laravel to ignore a folder when searching for classes ? Or am I simply not using the right method for what I want to do ?

  • 写回答

1条回答 默认 最新

  • douxian9060 2019-08-12 13:48
    关注

    You can exclude classes from the classmap(s) as follows in your composer.json.

    {
        "autoload": {
            "exclude-from-classmap": ["/Tests/", "/test/", "/tests/"]
        }
    }
    
    

    Further information can be found in composer's documentation chapter

    This will prevent the error-message in Laravel.

    Using this technique - as in your case - for packaging classes having invalid PSR-0/4 namespaces is bad practice.

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

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: