duangu1878 2017-03-10 23:47
浏览 16
已采纳

未找到类Die和Dump环境变量键

I am going through a laravel tutorial and the section I am stuck on is called "The Service Container" Basically I just grab a environment variable and spit it out to the page with a dd() die and dump. However I get a class not found error. I know it must be a small bug, but cant quite figure it out. I tried running composer dump-autoload with no luck.

Here is my code

routes/web.php

App::bind('App\Billing\Stripe', function(){

    return new \App\Billing\Stripe(config('services.stripe.secret'));

});

$stripe = App::make('App\Billing\Stripe');

dd($stripe);

app/billing/Stripe.php

namespace App\Billing;

class Stripe{

  protected $key;

  public function __construct($key){

    $this->key = $key;

  }

}
  • 写回答

1条回答 默认 最新

  • doujie4344 2017-03-10 23:58
    关注

    There is no need here for dump-autoload because you're creating a new namespace inside psr-4 confiugred folder app.

    The solution is to rename the folder billing to a capital case, because laravel uses composer autoload following psr-4 standard which states that namespace matches the folder name in a case sensitive way.

    Note : there are alternative autoloading schemes provided by composer that may need composer dump-autoload or editing composer.json when a new file is created

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分