Laravel项目在更改后自动刷新 [英] Laravel project auto refresh after changes

查看:525
本文介绍了Laravel项目在更改后自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有一种方法可以在Laravel项目中运行代码更改,而无需每次都刷新页面.

Does anyone know if there is a way to run the code changes in a Laravel project without refreshing the page every time.

我知道要查看所需的更改

I know that to see the changes I need to

php artisan serve

但是我每次都这样做,这很令人沮丧.

but I do it every time and it is kind of frustrating.

还是谢谢你.

推荐答案

您可以使用 Laravel Mix .

根据文档的这部分,您需要编辑webpack.mix.js文件,并将其添加到末尾:

According to this part of the documentation, you need to edit your webpack.mix.js file, and add this to the end:

mix.browserSync('127.0.0.1:8000');

它需要与php artisan serve命令的输出匹配,您在其中找到了类似以下内容的行:

It needs to match to the output of the php artisan serve command, where you found a line something like this:

Laravel development server started: <http://127.0.0.1:8000>

此后,您必须同时运行php artisan servenpm run watch命令.编辑文件时,必须离开以同时运行两个命令.

After this, you have to run the php artisan serve, and the npm run watch command simultaneously. You must leave to run both commands while you edit your files.

注意:第一次运行npm run watch时,它将安装其他组件.但是,命令输出在这一点上非常清楚.如果一切正常,Laravel Mix会自动使用http://localhost:3000或类似的方式打开浏览器.

Note: The first time you run the npm run watch, it installs additional components. But the command output is quite clear on that. If everything is in order, Laravel Mix automatically opens your browser with http://localhost:3000, or something like this.

这篇关于Laravel项目在更改后自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆