LoginSignup
3
3

More than 5 years have passed since last update.

laravel を NetBeans でステップ実行しようとしたら NotFoundHttpException

Posted at

現象

NetBeans のデフォルトでは php の最初の実行文(laravel の場合は public/index.php:22 の require 文)で止まるようになっています。デバッグ開始ボタンを押すとその行でちゃんと止まるので、xdebug 自体は問題なさそう。

ただ、その後実行継続ボタンを押すと、なぜか
NotFoundHttpException in RouteCollection.php line 161:
と言われます。ちなみに、デバッグボタンではなくて単に実行ボタンを押しても同様。

NetBeans を通さずに、対象の URL を単にブラウザで開くと正しく表示されます。

環境構築手順

https://github.com/hotta/laravel-centos7 に従って laravel 環境構築
その後、$ ansible-playbook /etc/ansible/jobs/xdebug.yml で xdebug 導入。

母艦(Windows10)には元々 NetBeans 8.1 が入っていたので、新しくプロジェクトを作ってプロジェクトURLをVagrant 配下の VM (laravel.local) に向けます。laravel.local は母艦の hosts ファイルに登録してあります。

実行開始ファイルは public/index.php とします。

laravel-netbeans.png

NetBeans 自体の導入については、過去記事を参照してください:
http://net-newbie.com/cakephp/xdebug-netbeans/

原因

エラーメッセージの通り、経路がない(laravel から認識できない)のだろうということで、以下を追加:

laravel/app/Http/routes.php
--- routes.php  2016-09-23 10:18:53.202926712 +0900
+++ laravel/app/Http/routes.php 2016-09-23 10:18:57.578792645 +0900
@@ -18,6 +18,7 @@
 Route::get('/{name}', function ($name) { return 'hello! ' . $name; });
 Route::get('/', function () { return view('posts.index'); });
 Route::get('/', 'PostsController@index');
+Route::get('/public/index.php', 'PostsController@index');
 Route::get('/posts/create', 'PostsController@create');
 Route::get('/posts/{id}', 'PostsController@show');
 Route::get('/posts/{id}/edit', 'PostsController@edit');

これで無事に動くようになりました。

3
3
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
3
3