gpt4 book ai didi

php - Laravel不上我的课

转载 作者:行者123 更新时间:2023-12-03 08:05:33 26 4
gpt4 key购买 nike

我收到的错误消息:

我的设置:

我已经在classes文件夹中创建了一个app文件夹,并在Alert.php内创建了app\classes
app\start\global.php中,代码是这样的:

ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/classes', // This line is the one I've added.
));

composer.joson中:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/classes"
]

之后,我运行了 composer dump-autoload
并且我在 'Alert'=>'Alert'aliases数组中添加了 app\config\app.php
我在 app\classes\Alert.php中的类(class):
<?php
class Alert {
static function new($type, $message){
if(Session::has("alert_type") && Session::has("alert_message")) {
$alert_type = Session::get("alert_type");
$alert_message = Session::get("alert_message");
} else {
$alert_type = array();
$alert_message = array();
}
$alert_type[] = $type;
$alert_message[] = $message;
Session::flash("alert_type", $alert_type);
Session::flash("alert_message", $alert_message);
}
}

filters.php中:
Route::filter('auth', function()
{
if (Auth::guest()) {
$alert_type = "danger";
$alert_message = "<strong>Error: </strong>You need to sign in before continue.";
Alert::new($alert_type, $alert_message);
return Redirect::intended('/');
}
});

最佳答案

new是PHP中的reserved keyword。为您的静态方法使用另一个名称,就可以了。

关于php - Laravel不上我的课,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21156750/

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