为什么在我直接称之为laravel5时找不到类名

时间:2022-10-18 14:59:48

I have to similar classes Laminat and Linoleum

我有类似的Laminat和油毡类

<?php namespace App\Http\Controllers\Parsing\Samara; class Laminat extends BaseSupply {
public $manufacture = 'Без производителя';
public $class = 'null';
public $depth = 'null';
public $collection = 'Без коллекции'; }

Linoleum :

油毡:

<?php namespace App\Http\Controllers\Parsing\Samara; class Linoleum extends BaseSupply {
public $manufacture = 'Без производителя';
public $collection = 'Без коллекции';
public $width = 'null'; }

and i trying to use it like

我想尝试使用它

 $path = "App\Http\Controllers\Parsing\Samara\Linoleum";
 $item = new $path();
 dd($item);

if i create instance of laminat it responses with dd

如果我创建了laminat的实例,它会用dd响应

firstPic

firstPic

if i create instance of linoleum it responses with dd

如果我创建油毡的实例,它用dd响应

secondPic

secondPic

What am i making wrong with this?

我弄错了什么?

1 个解决方案

#1


1  

The problem was, that theese classes was not in autoload file. So i ran theese comands

问题是,theese类不在自动加载文件中。所以我运行了这些命令

composer dump-autoload php artisan optimize

composer dump-autoload php artisan optimize

and classes was added to autoload file and everything works correctly.

和类被添加到自动加载文件,一切正常。

#1


1  

The problem was, that theese classes was not in autoload file. So i ran theese comands

问题是,theese类不在自动加载文件中。所以我运行了这些命令

composer dump-autoload php artisan optimize

composer dump-autoload php artisan optimize

and classes was added to autoload file and everything works correctly.

和类被添加到自动加载文件,一切正常。