LoginSignup
8
4

More than 3 years have passed since last update.

【Laravel】railsのbinding.pryみたいにデバッグする

Last updated at Posted at 2020-02-18

【laravel5】 tinkerを利用してpryのように楽にデバッグする!
この記事を参考にしました。

ポイント1  デバッグしたいところにeval(\Psy\sh());を置く。


public function update(ArticleRequest $request, $id)
    {
        $article = Article::findOrFail($id);
        $article->update($request->validated());
        eval(\Psy\sh());
        return redirect()->route('articles.show',$article->id)->with('message', '記事を更新しました。');
    }

ポイント2  php -S localhost:8000 -t public server.phpでサーバーを立てる。

(今の場合)更新ボタンを押す=> : q で、コンソールに入れる。

スクリーンショット 2020-02-18 10.47.19.png

こんな感じでデバッグできる!!

rails cと同じことがしたければphp artisan tinkerでいける。

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4