You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Livewire在XAMPP环境下非php artisan serve运行故障排查求助

XAMPP环境下Laravel Livewire非php artisan serve模式故障解决方法
  • 配置XAMPP虚拟主机(核心解决步骤)
    直接访问public目录会导致Livewire的资源路径、路由解析异常,必须配置虚拟主机:

    1. 打开XAMPP安装目录下的apache/conf/extra/httpd-vhosts.conf,添加以下配置(替换为你的项目路径):
      <VirtualHost *:80>
          DocumentRoot "C:/xampp/htdocs/your-laravel-project/public"
          ServerName your-project.test
          <Directory "C:/xampp/htdocs/your-laravel-project/public">
              AllowOverride All
              Require all granted
          </Directory>
      </VirtualHost>
      
    2. 编辑系统hosts文件:
      • Windows:C:\Windows\System32\drivers\etc\hosts
      • Linux/macOS:/etc/hosts
        添加一行:127.0.0.1 your-project.test
    3. 重启XAMPP的Apache服务,通过http://your-project.test访问项目,禁止直接访问public目录
  • 修正项目环境配置

    1. 打开项目根目录的.env文件,设置正确的APP_URL:
      APP_URL=http://your-project.test
      
    2. 清除配置缓存,避免旧配置生效:
      php artisan config:clear
      
  • 验证Livewire资源与路由

    1. 重新发布Livewire静态资源,确保路径正确:
      php artisan livewire:publish --assets
      
    2. 查看页面源代码,确认Livewire的JS文件路径为http://your-project.test/livewire/livewire.js,而非相对路径
    3. 检查路由冲突,执行php artisan route:list,确保没有自定义路由覆盖Livewire的/livewire/*路由

内容的提问来源于stack exchange,提问作者อนันดา สองสกุล

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 04:05:24