Php 如何在Laravel 8中使用Form Builder

Php 如何在Laravel 8中使用Form Builder,php,laravel,formbuilder,Php,Laravel,Formbuilder,我尝试在Laravel 8中使用以下软件包: 在文档中,它说路线应该如下所示: Route::get('songs/create', [ 'uses' => 'SongsController@create', 'as' => 'song.create' ]); Route::post('songs', [ 'uses' => 'SongsController@store', 'as' => 'song.store' ]); 这不适用于L

我尝试在Laravel 8中使用以下软件包:

在文档中,它说路线应该如下所示:

Route::get('songs/create', [
    'uses' => 'SongsController@create',
    'as' => 'song.create'
]);

Route::post('songs', [
    'uses' => 'SongsController@store',
    'as' => 'song.store'
]);
这不适用于Laravel 8,因此我根据以下帖子更改了代码:

但现在,当我转到/songs/create时,我得到以下错误:

Symfony\Component\Routing\Exception\RouteNotFoundException

未定义路由[song.store]


如何使它在Laravel 8中工作,该软件包应该支持它?

您收到的错误表明song.store没有定义,这是正确的,因为您给了它一个名称,而现在您没有根据给定的代码定义它。试试这个

Route::get('songs/create', [
    SongsController::class, 'create'
])->name('song.create');

Route::post('songs', [
    SongsController::class, 'store'
])->name('song.store');
在表单中,您可能使用命名的route song.store

Route::get('songs/create', [
    SongsController::class, 'create'
])->name('song.create');

Route::post('songs', [
    SongsController::class, 'store'
])->name('song.store');