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

Laravel Sail中开发包代码修改不同步,是否需额外配置?

Fixing Laravel Package Code Sync Issues with Sail

Great question—your setup is on the right track, but there are a few common Sail-specific quirks that might be preventing your package changes from syncing. Let’s walk through the fixes step by step:

While path repositories usually create symlinks by default, adding an explicit option ensures Composer never falls back to copying files (which would break real-time sync). Update your main project’s composer.json repositories section:

"repositories": [
    {
        "type": "path",
        "url": "../package",
        "options": {
            "symlink": true
        }
    }
],

After this change, run sail composer update your-vendor/your-package inside your Sail container to re-establish the symlink properly.

2. Clear Laravel’s Caches

Laravel caches class maps, config, routes, and views aggressively—this often hides package changes. Clear all caches in the Sail container:

sail artisan cache:clear
sail artisan config:clear
sail artisan route:clear
sail artisan view:clear

Also regenerate Composer’s autoload files to pick up any new or modified classes:

sail composer dump-autoload

3. Fix File Permissions for Sail

Sail runs as a non-root sail user, so your package directory might have permissions that block container access. On your host machine, run these commands to set correct ownership and permissions:

chown -R $USER:$USER code/package
chmod -R 755 code/package

This ensures the Sail container can read and write to your package files without restrictions.

4. Restart Sail to Refresh Mounts

Sometimes the Docker container doesn’t pick up symlink changes immediately. Restarting Sail will refresh the file system mount:

sail down
sail up -d

5. Verify Your Package’s Autoload Setup

Double-check your package’s composer.json to make sure its autoload configuration points to your source files correctly. For example:

"autoload": {
    "psr-4": {
        "YourVendor\\YourPackage\\": "src/"
    }
}

If you modified this section, run composer dump-autoload directly in your package directory to update the autoload map.

After trying these steps, any changes you make to the package directory should instantly reflect in the main project’s vendor symlink, and Laravel will pick them up without needing to reinstall the package.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 18:21:00