Framework: Composer and loading Models

Created on 29 Jan 2013  ·  3Comments  ·  Source: laravel/framework

When using the default User model in the app directory on the Laravel develop branch, Composer will throw this error message.

ErrorException: Warning: include(/home/george/Documents/Projects/laravel/app/models/user.php): failed to open stream: No such file or directory in /home/george/Documents/Projects/laravel/vendor/composer/ClassLoader.php line 183

It can be resolved by changing the model filename from User.php to user.php. Should the file name not be capitalized?

Most helpful comment

I was able to fix this issue by deleting the vendor directory and running php composer.phar install again.

All 3 comments

The model works out of the box. Paste code for how you used the model?

Hi Taylor

This is my controller which shows how I am using the model.

class LoginController extends BaseController {

    public function getIndex()
    {
        return View::make('login.index');
    }

    public function postIndex()
    {
        $user = array('username' => Input::get('username'), 'password' => Input::get('password'));

        if(Auth::attempt($user))
        {
            return Redirect::home();
        }

        return Redirect::back()->withInput();
    }
}

I was able to fix this issue by deleting the vendor directory and running php composer.phar install again.

Was this page helpful?
0 / 5 - 0 ratings