Laravel project auto refresh after changes

ぐ巨炮叔叔 提交于 2019-12-22 01:19:48

问题


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.

Thank you anyways.


回答1:


You can achieve this with Laravel Mix.

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');

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>

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.

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.



来源:https://stackoverflow.com/questions/49392001/laravel-project-auto-refresh-after-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!