问题描述
Laravel 8和jetstream,真的是新的吗?
我只是试图安装和播放它,但我真的不明白为什么我的个人资料照片没有显示图片。
更新配置文件信息表格
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:6IJbdi+QYczKeLT7yOw3OgPsHucXn1KxVUb27hTQKpU=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
.Env
'public' => [
'driver' => 'local','root' => storage_path('/public/storage'),'url' => env('APP_URL').'/public/storage/','visibility' => 'public',],
配置/文件系统
class InputKeyEvent implements InputCmd {
@Override
public void run(int inputSource,int displayId) {
String arg = nextArgrequired();
final boolean longpress = "--longpress".equals(arg);
if (longpress) {
arg = nextArgrequired();
}
do {
final int keycode = KeyEvent.keyCodeFromString(arg);
sendKeyEvent(inputSource,keycode,longpress,displayId);
} while ((arg = nextArg()) != null);
}
private void sendKeyEvent(int inputSource,int keyCode,boolean longpress,int displayId) {
final long Now = SystemClock.uptimeMillis();
int repeatCount = 0;
KeyEvent event = new KeyEvent(Now,Now,KeyEvent.ACTION_DOWN,keyCode,repeatCount,0 /*MetaState*/,KeyCharacterMap.VIRTUAL_KEYBOARD,0 /*scancode*/,0 /*flags*/,inputSource);
event.setdisplayId(displayId);
injectKeyEvent(event);
if (longpress) {
repeatCount++;
injectKeyEvent(KeyEvent.changeTimeRepeat(event,KeyEvent.FLAG_LONG_PRESS));
}
injectKeyEvent(KeyEvent.changeAction(event,KeyEvent.ACTION_UP));
}
}
解决方法
您需要先在公共目录下创建存储,然后将其链接。因此,首先进入laravel项目主文件夹,然后进入公共文件夹。如果存储链接不存在,请创建它。然后返回项目主文件夹并创建存储链接
$ cd (laravel project folder)
$ cd public
$ rm -r storage
$ cd ..
$ php artisan storage:link
应该可以解决问题了。
,在 .env 中设置你的 APP_URL ,我的是 APP_URL=http://localhost:8000 并在 CLI 中运行命令
php artisan storage:link
为 storage/app/public 创建符号链接,如果您还没有运行该命令,您将不会在仪表板中获得个人资料图片。
,个人资料图片存储成功吗?
(窗口),如果是,请执行以下步骤:
- 删除在/ project / public / 中创建的快捷方式文件夹存储
- 再次使用命令 php artisan storage:link
- 刷新网页即可解决。
您的问题是 .env 文件中的默认APP_URL设置:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:6IJbdi+QYczKeLT7yOw3OgPsHucXn1KxVUb27hTQKpU=
APP_DEBUG=true
APP_URL=http://localhost
Artisan serve命令在http://127.0.0.1:8000上启动了该应用程序,因此您相应地更改了APP_URL:
APP_URL=http://127.0.0.1:8000
我不推荐这样做。有时,由于各种原因,该命令可能会将端口更改为8001、8002等。
$ php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
Failed to listen on 127.0.0.1:8000 (reason: Address already in use)
Starting Laravel development server: http://127.0.0.1:8001
PHP 7.4.12 Development Server (http://127.0.0.1:8001) started
简单解决方案
只需注释或将您的 .env 文件中的APP_URL留空:
#APP_URL=http://localhost
APP_URL=
这将从配置文件图像中删除http:// localhost部分并解决问题:
<img src="/storage/profile-photos/photo.jpeg">
在生产环境中,您将始终具有不同的 .env 文件。
另外
您对config / filesystems.php文件进行了小的更改:
'public' => [
'driver' => 'local','root' => storage_path('/public/storage'),'url' => env('APP_URL').'/public/storage/','visibility' => 'public',],
原始设置为:
'root' => storage_path('/app/public'),
仅在删除并重建符号链接后,该功能才起作用。
但是现在,在项目目录中,您可能会遇到以下情况:
- public - storage + css - app + js - public - storage - profile-photos - public - public - storage - storage - profile-photos - profile-photos .htaccess + framework favicon.ico + logs index.php mix-manifest.json robots.txt web.config
基本上,您制作了一个新磁盘。我想这不是故意的。
另外,您的个人资料照片的网址中可能会有些混乱:
... / storage / public / storage / profile-photos /...。
您可以还原到原始设置,删除其他文件夹,然后重建sysmlink。
config / filesystems.php
'disks' => [
//...
'public' => [
'driver' => 'local','root' => storage_path('app/public'),'url' => env('APP_URL').'/storage',//...
],
,
我在使用 Laravel 8(当前最新版本)处理我的项目时遇到了同样的问题 以下是我解决这个问题的两种方法:
-
在第一种方法中,您可以轻松地将浏览器中的应用程序 URL 从 127.0.0.1:8000 更改为 localhost:8000,然后将 public/storage 与 storage/app/public 链接起来文件夹使用命令 php artisan storage:link
-
或者在第二种方法中,您可以编辑环境文件。转到环境配置文件 (.env) 并将 APP_URL 从 http://localhost 更改为 http://127.0.0.1:8000,然后使用命令将 public/storage 与 storage/app/public 文件夹链接 php artisan storage:link
最后,使用命令 php artisan serve 重新启动应用程序,现在它必须工作了。我希望它可以帮助任何面临此类问题的人。
,我这样做:删除filesystems.php上的(APP_URL) 这解决了我的问题,个人资料图片没有显示在jetstream上
'public' => [
'driver' => 'local','url' => env('').'/storage',
,
我也这样做了:从config / filesystems.php中删除了(APP_URL)
@Getter
@Setter
@Entity
@Table(name = "addresses")
public class Addresses {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long addressID;
private String addressStreet;
private String address_Business_Residential;
private String addressBusiness_Type;
private String addressComplex_Building;
private String addressSuburb;
private String addressCity_Town;
private String addressProvince;
private String addressPostal_Code;
@ManyToMany(fetch = FetchType.LAZY,cascade = { CascadeType.PERSIST,CascadeType.MERGE },mappedBy = "addresses")
private Set<User> user = new HashSet<>();
}
但这对我来说只解决了一半的问题。该图像现在仅显示在导航栏中,但仍未显示在个人资料页面中。 为此,我做到了: 在update-profile-information.blade.php文件中,我将图像源更改为
'public' => [
'driver' => 'local',
(可能不是一个适当的解决方案,但目前在我的学习项目中对我来说是有效的)
,在config / app.php中,APP_URL可能需要一个端口,例如:
'url'=> env('APP_URL','http:// localhost:8080'),
,在名为 jetstream.php 的 config 文件夹中找到文件,并在返回的数组中查找'features'键,并取消注释 Features :: profilePhotos()值。
之前:
'features' => [
// Features::profilePhotos(),// Features::api(),// Features::teams(),
之后:
'features' => [
Features::profilePhotos(),
,
对不起,我这个水平解决了这个问题
-
在名为jetstream.php的配置文件夹中找到文件,并在返回的数组中查找“功能”键,并取消注释
Features::profilePhotos()
-
转到.env并将应用uri更改为此
APP_URL=http://localhost:8000
-
在终端输入:
php artisan serve
,
使您的 .env APP_URL 正确并确保运行 php artisan storage:link。 https://github.com/laravel/framework/issues/34319#issuecomment-691677346
,console.log(data.map((d) => d.hwi.prs.map((p) => p.sound.audio)));
远足
,我遇到了同样的问题,只需运行 php artisan storage:link 就可以了。
注意:我在 laravel 的新启动时运行此命令并且没有更改我的存储路径设置(默认)
, ,如果您的 Jetstream 个人资料照片未显示,您必须执行简单的 3 个主要步骤
- 首先运行这个命令php artisan storage:link
- Features::profilePhotos(),从 config/jetstream.php 启用此功能
- 最后,主要是从 .env 文件中更改 APP_URL(这很重要),如果您的 APP_URL=http://localhost 这不会显示您,那么将其更改为 APP_URL= http://127.0.0.1:8000 或者如果您使用的是虚拟主机然后APP_URL= http://livewire_app.dev
看看这对我来说很好用