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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器