Class autoload in Laravel 4.1

I try to use Laravel and follow the official Laravel Eloquent documentation and several tutorials in reliable tuts plus sources

I created a model inside the application / models called Stack with a table in the database called stacks with a primary key column called id, which corresponds to the default values ​​of Laravels.

<?php (Stack.php)

class Stack extends Eloquent
{


}

$stacks = Stack::all();

However, when I run this model, I get the following error message.

Fatal error: Class 'Eloquent' not found in C:\www\laravelproject\app\models\Stack.php on line 4

Including official documentation and authoritative study guides, I also looked through 2 youtube tutorials, and it seems that there is no additional startup / including / requiring a mandatory declaration in any new specific model, so I assume there may be something else wrong.

, ? , ?

laravel.phar laravel .bat . ( )

, / .

  • Eloquent \laravel\framework\src\Illuminate\Database\Eloquent
  • , app/config/app.php. 'Eloquent' = > 'Illuminate\Database\Eloquent\Model'
  • , \Illuminate\Database\Eloquent\Model, , \Illuminate\Database\Eloquent\Model, Eloquent
  • Laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent, \laravel\framework\src\Illuminate\Database\Eloquent ..... ....
  • , composer create-project laravel/laravel -prefer-dist, , , 100%, , . /User.php , previuos ( laravel.phar).

.

+4
3

, "".

, /public/index.php.

app/public/index.php .

<?php
/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/../bootstrap/autoload.php';
+1

, . .

class Stack extends \Eloquent
{


}
0

Make sure you set an alias Eloquentin the application configuration. (Application / Config / app.php)

Alternatively use the class directly. I believe this:Illuminate\Database\Eloquent\Model

class Stack extends \Illuminate\Database\Eloquent\Model {}
0
source

Source: https://habr.com/ru/post/1538079/


All Articles