Question

I'm working on migrating an existing Laravel 3 application over to Laravel 4.1, and routes are kicking my butt right now. Here is the problem I'm having- in the old application we made frequent use of Route::controller() in the routes file. When I bring those entries over to the new application they seem to work, but they cause composer to get nasty.

For example I have this route:

Route::controller('templates', 'AdminTemplatesController');

Which is working as a route. But when I run composer update I get this error:

{"error":{"type":"ReflectionException","message":"Class AdminTemplatesController does not exist","file":"\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerInspector.php","line":28}}

I've tried stripping down and using Artisan to create an entirely new controller- same test, same fail.

Any ideas what I'm doing wrong?

Was it helpful?

Solution

Looks like you have to do it in steps:

1) Disable all of your routes

2) Execute composer update and make the process pass, you don't need your routes to do that

3) Reenable the controller route and fix the issue Laravel is having by not finding it, which could be:

  • Controllers folder not being loaded in composer.json
  • Namespace not being loaded in composer.json

In all of those cases, you have to be sure that you have your controllers in any of the files of the folder:

vendor/composer

For example, if you have the controllers folder in the autoload->classmap of composer.json, the file will be:

vendor/composer/autoload_classmap.php

Remember that every time you change composer.json, you have to

composer dumpautoload

So it recreates those files.

EDIT:

About your comment, I had similar problem once when my file was printed in command line, was happening because I had:

<?

instead of

<?php

This makes difference for Laravel.

OTHER TIPS

In Laravel 4 you use "Route::resource()". So your example would be Route::resource('templates', 'AdminTemplatesController');

http://laravel.com/docs/controllers#resource-controllers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top