我正在尝试将 S3 Multipart Uploader 从 Laravel 8 升级到 Laravel 9,并已按照文档中的概述升级到 Flysystem 3,并且没有依赖项错误https://laravel.com/docs/9.x/upgrade#flysystem-3。
我无法访问底层 S3Client 以创建分段上传。
// Working in Laravel 8
// Laravel 9 throws exception on getAdapter()
$client = Storage::disk('s3')->getDriver()->getAdapter()->getClient();
// Underlying S3Client is used to create Multipart uploader as below
$bucket = config('filesystems.disks.s3.bucket');
$result = $client->createMultipartUpload([
'Bucket' => $bucket,
'Key' => $key,
'ContentType' => 'image/jpeg',
'ContentDisposition' => 'inline',
]);
return response()
->json([
'uploadId' => $result['UploadId'],
'key' => $result['Key'],
]);
Run Code Online (Sandbox Code Playgroud)
然而,Laravel 9 抛出异常Call to undefined method League\Flysystem\Filesystem::getAdapter() …
当我尝试运行此命令 php artisan make:auth... 时出现以下错误。有什么方法可以运行此命令,或者此命令的任何替代方法,我应该为此命令安装 amy 软件包吗?
Command "make:auth" is not defined.
Did you mean one of these?
make:cast
make:channel
make:command
make:component
make:controller
make:event
make:exception
make:factory
make:job
make:listener
make:mail
make:middleware
make:migration
make:model
make:notification
make:observer
make:policy
make:provider
make:request
make:resource
make:rule
make:scope
make:seeder
make:test
Laravel Framework 9.8.1
Run Code Online (Sandbox Code Playgroud) Laravel 9 使用 vite Vue 3、Vue-router 运行命令 vite build 并关闭 vite 服务器,浏览器 url 中的所有链接均获取 '/build/'
在代码中
<router-link to="/index">Index</router-link>
<router-link to="/">Main</router-link>
<router-view></router-view>
Run Code Online (Sandbox Code Playgroud)
投票配置
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [
vue(),
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
});
Run Code Online (Sandbox Code Playgroud)
刀刃
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
@vite(['resources/css/app.css', 'resources/js/app.js'])
<!-- Styles --> …Run Code Online (Sandbox Code Playgroud) 我刚刚新安装了一个 Laravel 9 应用程序,使用 npm 添加了 select2 和 jquery,将我需要传递给 vite.config.js 和 app.js 的内容传递给了 vite.config.js 和 app.js,jquery 在 select2 加载之前就已加载,但 select2 仍然抛出异常
Uncaught ReferenceError: jQuery is not defined
at select2.min.js:2:241
at select2.min.js:2:249
Run Code Online (Sandbox Code Playgroud)
我什至制作了一个 div#test 并使用 jquery 在加载窗口时将“ok”放入其中,它更改为“ok”,但是为什么 select2 会抱怨呢?
包.json
"dependencies": {
"jquery": "^3.6.1",
"select2": "^4.1.0-rc.0"
}
Run Code Online (Sandbox Code Playgroud)
vite.config.json
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
resolve: {
alias: {
'$': 'jQuery',
},
},
});
Run Code Online (Sandbox Code Playgroud)
应用程序.js
import "./bootstrap";
import $ from "jquery";
window.$ = $;
// …Run Code Online (Sandbox Code Playgroud) 以下是我在 laravel 9 项目中的登录功能。我正在尝试通过创建身份验证令牌laravel-passport。
public function login(Request $request) {
$user = User::where('email', $request->email)->first();
if ($user) {
if (Hash::check($request->password, $user->password)) {
$token = $user->createToken('Laravel Password Grant Client')->accessToken;
$response['token'] = $token;
return response($response, 200);
} else {
$response = ["message" => "Password mismatch"];
return response($response, 422);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的回应是,
{
"token": {
"name": "Laravel Password Grant Client",
"abilities": [
"*"
],
"tokenable_id": 1,
"tokenable_type": "App\\Models\\User",
"updated_at": "2022-07-04T05:58:36.000000Z",
"created_at": "2022-07-04T05:58:36.000000Z",
"id": 62
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里没有得到任何令牌。请帮我解决这个问题。
如何确保用户在 Laravel-9 中登录后就无法再通过浏览器后退按钮转到登录页面?
我在互联网上搜索解决方案。我在几个地方读到这是不可能的或者我必须使用 Javascript。
可以肯定的是,我决定在这里发布我的问题,希望你能帮助我。
有什么办法可以做到这一点吗?如果解决方案是用javascript,我该如何用javascript解决这个问题?
谢谢
我正在进行一个新Laravel9的Vite3项目TailwindCss3。
仅使用npm run build不足以部署应用程序!
当我不运行 Vite 的开发服务器时,出现以下错误:
无法在 Vite 清单中找到文件:resources/css/app.css。
但当我使用时npm run dev一切正常!
我使用了以下命令:
laravel new vite-test --git &&
cd .\vite-test\ &&
npm i &&
npm install -D tailwindcss postcss autoprefixer &&
npx tailwindcss init -p &&
php ./artisan serve
Run Code Online (Sandbox Code Playgroud)
并按照文档编辑了以下文件:
<!-- resources\views\welcome.blade.php -->
<!DOCTYPE html>
<html lang="en">
<head>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
<div class="h-screen w-screen bg-red-500"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
// tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = { …Run Code Online (Sandbox Code Playgroud) 在 Laravel 中进行基于 phpUnit 的单元测试时,我发现了两种测试作业是否被调度的方法 -
1.
$this->expectsJobs(JobClassName::class);
2.
Bus::fake();
Bus::assertDispatched(JobClassName::class);
Run Code Online (Sandbox Code Playgroud)
在仔细检查 Laravel 文档后,我无法弄清楚上述哪一种方法是更好的方法以及这两种方法之间的功能差异是什么。
谁能帮我?我还是 Laravel 的初学者。所以,这个错误是我刚做git clone项目时出现的。之后我用 vsCode 打开项目,立即出现很多错误。
错误 :
未定义类型“Illuminate\Support\Facades\Route”。智能电话(1009)
未定义的函数“重定向”。因特莱芬斯(1010)
未定义类型“Auth”。智能电话(1009)
未定义的函数“响应”。因特莱芬斯(1010)
我非常感谢那些可以帮助我找到如何修复此错误的人。谢谢你!
大家好,我正在尝试使用 Laravel Socialite Package 来允许用户使用他们的 LinkedIn 帐户登录。我已经在 ENV 文件中设置了客户端 ID、秘密和 URL,如下所示:
LINKEDIN_CLIENT_ID=xyzSomeID LINKEDIN_CLIENT_SECRET=xyzSomeSecret LINKEDIN_URL=https://mydomainname.com/api/domain-login/linkedin/callback
但是当我尝试使用 LinkedIn 按钮登录时,出现以下错误
Unauthorized scope error scope profile is not authorized for your application LinkedIn Socialite login Laravel
几秒钟后,我被重定向回 URL,并出现以下错误
{"message":"Error occurred","data":"Client error: POST https://www.linkedin.com/oauth/v2/accessToken resulted in a400 错误请求 response:\n{\"error\":\"invalid_request\",\"error_description\":\"A required parameter \\\"code\\\" is missing\"}\n113"}
请注意:已启用使用 OpenID Connect 登录 LinkedIn。
任何这方面的提示都将受到高度赞赏。
我已经设置了运行良好的路线。开发者控制台已经设置并且工作正常。客户端 ID、Secret 和回调 URI 已添加到 ENV 文件中。
这是我的路线:
Route::get('domian-login/{provider}', [ControllerName::class, 'redirectToProvider']); Route::get('domain-login/{provider}/callback', [ControllerName::class, 'handleProviderCallback']); Route::post('domain/save-social-user', [ControllerName::class, 'saveSocialUser']);
laravel-9 ×10
laravel ×9
php ×3
vite ×2
amazon-s3 ×1
intelephense ×1
jquery ×1
laravel-8 ×1
laravel-jobs ×1
linkedin-api ×1
phpunit ×1
tailwind-css ×1
testing ×1
vue-router ×1
vuejs3 ×1
windows ×1