gpt4 book ai didi

php - Route.php 中的 UnexpectedValueException 行 639 : Invalid route action: [App\Http\Controllers\PortfolioController]

转载 作者:可可西里 更新时间:2023-11-01 00:02:17 24 4
gpt4 key购买 nike

为什么我会收到此错误。我创建了一个 PortfolioController。然后我用这个做了一条路线

Route::get('portfolio','PortfolioController');  

所以在我的 Controller 页面中我做了这个。

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class PortfolioController extends Controller
{
//This only gets exectued when we request /portfolio/Paintings using GET
public function getPaintings()
{
return 'This RESTful controller is working!';
}
}

我在输入 localhost/portfolio/paintings 时收到此错误

最佳答案

从代码的外观来看,您似乎正在尝试设置 implicit controller route .你很接近,但你的路线定义有点偏离。您需要使用 controller 而不是 get:

Route::controller('portfolio','PortfolioController');

关于php - Route.php 中的 UnexpectedValueException 行 639 : Invalid route action: [App\Http\Controllers\PortfolioController],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33182331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com