我创建了一个作曲家程序包,但是当我在Laravel中使用它时,出现以下错误:
Class 'Markok\Example_for_composer\Example_for_composer' not found
我的控制器:
use Markok\Example_for_composer\Example_for_composer;
class NotesController extends Controller
{
public function index()
{
$a = new Example_for_composer();
$a->greet("Mark");
}
}
Composer.json:
"autoload": {
"psr-4": {
"App\\": "app/",
"Markok\\Example_for_composer\\": "packages/markok/example_for_composer/src"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
markok / example_for_composer / src / Example_for_composer.php:
<?php
namespace Markok\Example_for_composer;
class Example_for_composer
{
public function greet(String $sName)
{
return 'Hi ' . $sName . '! How are you doing today?';
}
}
可能是什么问题?