运行composer install命令时出现异常错误。它需要 PHP 7.3,而我有 PHP 8.0.0。这个问题与Composer 中的 Override PHP base dependency不同,因为我的 PHP (8.0.0) 版本高于它所需的版本,只是想知道为什么它不起作用?
Problem 1
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement. Problem 2
- asm89/stack-cors is locked to version v2.0.1 and an update of this package was not requested.
- asm89/stack-cors v2.0.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement. Problem 3
- laravel/framework is locked to version v8.10.0 and …Run Code Online (Sandbox Code Playgroud) 这几天我一直在为这个问题揪心。
我有一个 Laravel Web 应用程序,我正在尝试将其部署到我的网络服务器。我几周前开始制作该应用程序,并从最新稳定版本的全新 Laravel 安装开始。
当我第一次尝试通过 Composer 安装 Laravel 时,它告诉我我的 PHP 版本已经过时。我需要 7.3 或更高版本并安装了 7.2。我继续按照本指南安装 php 7.4。
起初,我在 Apache 中收到默认的 503 服务不可用错误,我能够将其确定为另一个域虚拟主机上的 ProxyPass 错误。当我检查 Apache 错误日志时,这已显示在其中。
现在,我只是禁用了该网站,因为它已经有一段时间没有使用了。
这样做后,我现在得到一个样式为“500 | 服务器错误”的屏幕,它与 Laravel 默认错误代码屏幕相匹配。但是,storage/logs/laravel.log当我去检查时没有新的错误。如果我尝试运行 artisan 命令,因为php artisan migrate日志确实将这些错误的输出正确写入文件。所以根本无法写入日志并不是权限错误。
就目前情况而言,我已经在我的网络服务器上安装了以下内容。
到目前为止我已经尝试过...
.env已成功创建并具有正确的权限。(确实如此)trueinconfig/app.php并重新加载配置缓存php artisan config:cache …我面临一个独特的问题,我的数据库中只有 3 个用户数据 John、Cindy 和 Carla,我使用用户名 john 登录,但我得到 Carla 的身份验证数据,它应该是 john 的身份验证数据。
这是我的登录功能LoginController.php
public function login(Request $request) {
$this->validateLogin($request);
$credentials = ['user_id' => \Arr::get('user_id','', $request->input('user_id')),
'password' => \Arr::get('password','', $request->input('user_password'))
];
if(Auth::attempt($credentials)){
return redirect()->intended($this->redirectPath());
}
return back()->withInput($request->except('password'))->withErrors(['Username atau Password Wrong! ']);
}
Run Code Online (Sandbox Code Playgroud)
这是我的用户模型
class User extends Authenticatable {
use Notifiable;
use HasRoles;
protected $table = "m_user";
protected $primaryKey = "user_id";
public function getAuthPassword() {
return $this->hash_password;
}
protected $fillable = [
'user_id', 'nama', 'user_password','hash_password','role', 'company','is_active','created_by','created_at','updated_by','updated_at'
];
protected …Run Code Online (Sandbox Code Playgroud) 我是 Laravel 的新手。Visual Studio 代码在我的 Laravel 项目文件上显示错误laravel>routes>web.php,但程序运行良好,没有任何错误。
关于这是如何工作的有什么解释吗?
我是 Laravel 8 的新手。在之前的 Laravel 版本 7 中,我们可以通过这种方式传递子域名
Route::group( [ 'domain' => '{admin}.example.com' ], function () {
Route::get('/index', 'HomeController@index($account)' );
}
Run Code Online (Sandbox Code Playgroud)
但是,在 Laravel 8 中,调用Controller 的结构代码被这样改变了。
Route::domain('{admin}.example.com')->group(function () {
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
});
Run Code Online (Sandbox Code Playgroud)
我一直在寻找文档,但尚未找到。您可以向我展示文档或帮助我将子域从web.php发送/传递到控制器吗
我们正在向我们的团队频道发送一条松弛消息,因此不使用可通知的实例。我就是这样做的——
Notification::route('slack', env('SLACK_URL'))
->notify(new StaffNotification());
Run Code Online (Sandbox Code Playgroud)
并在 StaffNotification 中
public function toSlack() {
return (new SlackMessage)->content('New Staff Message.');
}
Run Code Online (Sandbox Code Playgroud)
我应该如何测试 StaffNotification,因为所有可用的断言都接受第一个参数作为可通知的?
我试图从没有关系的模型中加载所有行。
属性 $with it 不是在我的事件模型上设置的事件,但是当我这样做时
$events = Event::all();
Run Code Online (Sandbox Code Playgroud)
我的所有关系都已加载,我可以使用 dbquerylog 查看所有查询。
我不明白为什么加载这些关系,
请帮我 !感谢您。
我正在使用 Laravel 8。
这是一个例子。
class Event extends Model {
public function items() {
return $this->hasMany(Item::class);
}
public function items2() {
return $this->hasMany(Item2::class);
}
public function items3() {
return $this->hasMany(Item3::class);
}
public function items4() {
return $this->hasOne(Item4::class);
}
}
$events = Event::all();
Run Code Online (Sandbox Code Playgroud) 我的应用程序使用 Gmail 发送电子邮件,但当它尝试发送电子邮件时,Gmail 返回错误消息“无法使用 3 个可能的身份验证器在 SMTP 服务器上使用用户名“”进行身份验证。身份验证器登录返回预期响应代码 235但收到代码“535”,并显示消息“535-5.7.8 用户名和密码不被接受。”我正在使用 Google Workplace,因此电子邮件会使用我公司的域名发送。有一个用于发送电子邮件的通用 Gmail 帐户,其Gmail SMTP 配置信息在应用程序中正常。为什么不起作用?修复方法是什么?
是否可以在刀片中按原样显示响应 JSON?喜欢
{{$集合}}
[
{
"id":1,
"name":"Quam accusantium dolore qui.",
"description":"Ipsa mollitia et rerum sint.",
...
}
]
Run Code Online (Sandbox Code Playgroud)
我希望它的格式像上面一样,以使其更具可读性。
尝试验证有效的 24 小时时间。
请求转储,
#parameters: array:6 [?
"_token" => "mP2b6fmvlQG6SMgMwz9VI9kZEXtjXqp7hXUjdWdZ"
"email" => null
"ageLimit" => null
"timeFrom" => "0:00"
"timeTo" => "0:00"
"alowed_days" => array:7 [?]
]
Run Code Online (Sandbox Code Playgroud)
控制器验证
$validation = $request = $request->validate([
'email' => 'email|required',
'ageLimit' => 'required|numeric',
'timeFrom' => 'date_format:H:i',
'timeTo' => 'date_format:H:i',
)];
Run Code Online (Sandbox Code Playgroud)
这是出于某种原因失败了吗?我收到“来自的时间与格式 H:i 不匹配。”
我不明白什么?
我尝试从数据库中选择create_data,数据库中的日期格式类似于“2021-05-18 11:06:01”,但是当我检索并显示它时,它将显示类似于“2021-05”的格式-18T03:06:01.000000Z”。有谁知道为什么会变成这样吗?我想要的日期实际上就像数据库存储“2021-05-18 11:06:01”。然而,DB内的create_date格式是UTC +8,但接收时会显示UTC格式。
数据返回
[0] => Array (
[id] => 1
[log_name] => login
[description] => login
[subject_type] => App\Models\Users
[subject_id] => 0
[causer_type] => App\Models\User
[causer_id] => 2
[properties] => ""
[created_at] => 2021-05-18T03:06:01.000000Z
);
Run Code Online (Sandbox Code Playgroud)
代码
$lastLoggedActivity = ActivityLog::where('causer_id', $userid)
->orWhereIn('subject_id', $selectparentid)
->with('getLogType')
->with('getCauserDetails')
->orderBy('created_at', 'desc')
->get()
->toArray();
Run Code Online (Sandbox Code Playgroud) env()支持 Laravel 6.20 应用程序,我看到控制器中调用了很多方法。它在我这边不起作用,所以我在 config/app.php 文件中创建了一个包装器,并使用它使其工作。我必须在应用程序中进行很多类似的更改才能使其正常工作......
但看起来这env() 对我的客户在实时和开发人员服务器上有效。我知道env() 直接调用控制器是一种不好的方法,但想知道为什么它在服务器上有效?有一些常见的 PHP 配置吗?
谢谢!