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

Laravel 7.*版本自定义Sail容器安装脚本执行后Sail缺失问题求助

Troubleshooting Laravel Sail Installation Failure with Laravel 7.x

Let's break down why you're hitting this issue and walk through the fixes step by step:

First, the core problem: Laravel 7.x doesn’t include Sail out of the box. Sail was introduced as the official Docker development tool starting with Laravel 8, so running sail:install directly on a fresh Laravel 7 project will fail—this command simply doesn’t exist in Laravel 7’s default command set.

1. Install Sail Manually for Laravel 7.x

Since Sail isn’t bundled with Laravel 7, you need to add it as a compatible Composer dependency first. Sail’s ^1.0 version works with Laravel 7.x (newer Sail versions require Laravel 8+).

Adjust Your Initial Docker Script

Update your command to include installing the compatible Sail package before running sail:install:

docker run --rm -v $(pwd):/opt -w /opt laravelsail/php74-composer:latest bash -c "composer create-project laravel/laravel my-app \"7.*\" && cd my-app && composer require laravel/sail:^1.0 --dev && php artisan vendor:publish --provider=\"Laravel\Sail\SailServiceProvider\" && php artisan sail:install --with=mysql"

Step-by-Step Manual Alternative

If you prefer to run commands locally after creating the project:

  • Navigate to your project directory: cd my-app
  • Install the compatible Sail package: composer require laravel/sail:^1.0 --dev
  • Publish Sail’s configuration files: php artisan vendor:publish --provider="Laravel\Sail\SailServiceProvider"
  • Run the Sail setup command: php artisan sail:install --with=mysql

2. Verify the Installation

After running the adjusted script or manual commands, check if the Sail binary exists:

ls ./vendor/bin/sail

If this succeeds, you can start your Sail environment with:

./vendor/bin/sail up

3. Troubleshooting Edge Cases

  • Dependency Conflicts: If Composer throws errors, double-check you’re specifying laravel/sail:^1.0—newer versions only support Laravel 8+.
  • Permissions: Ensure your host machine’s $(pwd) directory has read/write permissions for the Docker user to avoid file access issues.
  • Image Compatibility: Stick with laravelsail/php74-composer for Laravel 7.x, as it’s built for PHP 7.4 (the recommended PHP version for Laravel 7).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 15:37:38