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

官方文档仅提供VSCode操作指引,如何使用PhpStorm访问Laravel Sail创建的文件?

Accessing Laravel Sail Files with PhpStorm

Hey there! I’ve got you covered when it comes to working with Laravel Sail files in PhpStorm. Let’s walk through the simplest and most reliable methods:

Laravel Sail uses Docker volume mounting to sync your local project folder with the container’s /var/www/html directory by default. This means you don’t need to connect directly to the container—just:

  • Make sure your Sail containers are running:
    sail up -d
    
  • Open PhpStorm, then select File > Open and choose your local Laravel project root folder.

Any changes you make in PhpStorm (local files) will automatically sync to the Sail container, and vice versa.

Fixing Permission Issues

If you run into file permission errors (common on Linux/macOS), update your .env file with your local user’s UID and GID:

  1. Run these commands in your terminal to get your user IDs:
    id -u # Gets your UID
    id -g # Gets your GID
    
  2. Add these lines to your .env file:
    WWWUSER=your_uid_here
    WWWGROUP=your_gid_here
    
  3. Restart the Sail containers to apply the changes:
    sail down && sail up -d
    

2. Connect Directly to the Sail Container (Advanced)

If you need to access files directly in the Docker container (not recommended for daily use), set up a remote interpreter in PhpStorm:

  • Open File > Settings > Languages & Frameworks > PHP > CLI Interpreter
  • Click the + button and select From Docker, Vagrant, VM, WSL, Remote...
  • Choose Docker as the environment, then select your Sail container (usually named laravel.test)
  • Set the PHP interpreter path to /usr/bin/php (the default path in Sail’s PHP container)
  • Once configured, you can use the Remote Host tool window in PhpStorm to browse and edit files directly in the container.

Troubleshooting Tips

  • If files aren’t syncing, double-check your docker-compose.yml to confirm the volume mount is set correctly (default is ./:/var/www/html)
  • Ensure Sail containers are running without errors—use sail logs to check for issues
  • If PhpStorm doesn’t detect changes, try refreshing the project (File > Reload All from Disk)

Hope these steps help you work seamlessly with Laravel Sail in PhpStorm!

内容的提问来源于stack exchange,提问作者Lamantinoss

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 14:23:12