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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配