douzhi6365 2014-08-24 10:23
浏览 54
已采纳

Laravel 4自定义程序包未出现在autoload_namespace.php中

Laravel 4 custom package not appearing in autoload_namespace.php

I have tried to create a custom package by creating a workbench package in one of my laravel apps, committing it to github and then installing it in a different package. My problem is that the namespace map is not being added to autoload_namespace.php and the knock on effect of this is that the line Markfee\Responder\ResponderServiceProvider in my providers array causes the following error when i run:

php artisan dump-autoload

Error Output:

PHP Fatal error: Class 'Markfee\Responder\ResponderServiceProvider' not found in /media/sf_wwwshare/feenance/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157

The package can be found at:

https://github.com/markfee/responder.git

I include the package with the following entries in my composer.json file

"repositories": {
  "responder": {
    "type": "package",
    "package": {
      "name": "markfee/responder",
      "description": "Simple responder class for responding with json from api",
      "version": "0.1.0",
      "source": {
        "type": "git",
        "url": "https://github.com/markfee/responder.git",
        "reference": "a7a24c82479fc01ec0c06833690bfd2eeee9e47d"
      }
    }
  }
},
"require": {
  "laravel/framework": "4.2.*",
  "markfee/responder": "0.1.*"
},

If anyone can shed any light I'd be very greatful. Please ask if you need any further details.

  • 写回答

2条回答 默认 最新

  • dthl8036 2014-08-24 11:56
    关注

    You did the complicated way by providing a package definition for that repository. If you do that, this package is a complete replacement for any composer.json in that repository, and this should only be used in case there is none.

    You didn't add the autoloading definition into that package, so it is correctly missing in your autoloading.

    Suggestion: Avoid using type:package in your own composer.json file. Simply use type:vcs if the repository already has a composer.json.

    If you want to use the master branch just like a tagged version, you can add an alias in your require statement: "markfee/responder": "dev-master as 0.1.0". You could also clone that repo and tag the commit you want in your own local copy, and reference your own repo instead. Or try to convince the maintainer to tag a version and add his repo to packagist.org.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵