m2mdas / phpcomplete-extended

A fast, extensible, context aware autocomplete plugin for PHP composer projects with code inspection features.
MIT License
216 stars 23 forks source link

Laravel 4.0 project issue when generating index #20

Closed jasin closed 10 years ago

jasin commented 10 years ago
Generating autoload classmap
Generating index...
PHP Fatal error:  Call to a member function where() on a non-object in /usr/local/docs/laravel.coleburt.com/develop/vendor/laravel/f
ramework/src/Illuminate/Routing/Router.php on line 295
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function where() on a non-o
bject","file":"\/usr\/local\/docs\/laravel.coleburt.com\/develop\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php",
"line":295}}

code that phpcomplete-extended is complaining about

/**
 285      * Add a fallthrough route for a controller.
 286      *
 287      * @param  string  $controller
 288      * @param  string  $uri
 289      * @return void
 290      */
 291     protected function addFallthroughRoute($controller, $uri)
 292     {
 293         $missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod');
 294
 295         $missing->where('_missing', '(.*)');
 296     }

I am using laravel 4.0

surfdemon commented 10 years ago

I have the exact same problem apart from the line 295 is listed as line 308 but the code looks exactly the same.

surfdemon commented 10 years ago

Done "php composer.phar update" and getting the same error but this time it says it is line 310 which is again the same line as above that is listed as 295 and is the same function allFallthroughRoute

m2mdas commented 10 years ago

Have you installed phpcomplete-extended-laravel plugin?

surfdemon commented 10 years ago

Yes, both phpcomplete-extended and phpcomplete-extended-laravel were installed today

m2mdas commented 10 years ago

Hmm, at first glance, it seems to be a problem is related to route filter. I am trying to reproduce the error here.

m2mdas commented 10 years ago

I could not reproduce the error. Can you list the route declarations of app/routes.php by issuing :g/Route::/p and paste the output here. It would be helpful if you list which plugins are you using. Also the problem is occurring during bootstrapping the framework. Does the project works correctly in browser?

jasin commented 10 years ago

I do have filters in UserController and AdminController. They make sure the user is logged in and have the proper authorization before they can access the page. Would it help to see the filter.php as well? Yes, the webpage works. it is a work in progress but you can access it at laravel.coleburt.com and see the filters in action for yourself.

:g/Route::/p
Route::get('/', function()
Route::get('test', function() {
Route::get('logout', function() {
Route::get('user/index', array('as' => 'home', 'uses' => 'UserController@getIndex'));
Route::get('user/predictions', array('as' => 'predictions', 'uses' => 'UserController@getPredictions'));
Route::get('admin/index', array('as' => 'admin', 'uses' => 'AdminController@getIndex'));
Route::get('admin/managedb', array('as' => 'managedb', function(){ return View::make('admin.managedb')->withTitle('manage database'); }));
Route::post('admin/season', array('before' => 'csrf|admin', 'uses' => 'AdminController@postSeason'));
Route::controller('login', 'LoginController');
Route::controller('admin', 'AdminController');
Route::controller('user', 'UserController');
Route::post('test', array('before' => 'csrf', 'uses' => 'TestController@test'));

and what plugins exactly are you talking about? Vim plugins


" My bundles here:
Bundle 'captbaritone/better-indent-support-for-php-with-html'
Bundle 'Shougo/vimproc'
Bundle 'Shougo/unite.vim'
Bundle 'm2mdas/phpcomplete-extended'
Bundle 'm2mdas/phpcomplete-extended-laravel'
Bundle 'm2mdas/phpcomplete-extended-symfony'
" original repos on GitHub
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'HTML5-Syntax-File'
" non-GitHub repos
"Bundle 'git://git.wincent.com/command-t.git'
Bundle 'git://github.com/othree/html5-syntax.vim.git'
" Git repos on your local machine (i.e. when working on your own plugin)
"Bundle 'file:///Users/gmarik/path/to/plugin'
" ...
m2mdas commented 10 years ago

Well I actually meant Laravel bundles. But that wouldn't be necessary as the problem is elsewhere. The problem was not handling of Route::controller() route declaration. I normally used Route::resource() for resource controllers, thats why I forgot to handle Route::controller() :). I fixed the issue. Please update phpcomplete-extended-laravel and run :PHPCompleteExtendedGenerateIndex.

P.S, a disclaimer. I last worked on a Laravel project 4 months ago with limited set of bundles. In the meantime Laravel 4.1 is released. There may be a possibility of occurring index generating error. If you face any error don't hesitate to file bug report. I will try to fix the error as soon as I can.

jasin commented 10 years ago

Yes, that fixed the issue, index generates now with no errors. Thanks for the speedy fixes.

surfdemon commented 10 years ago

I can confirm it is working for me as well, thank you as well for the fast fix!