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

Mac环境下无法在PhpStorm中创建Laravel项目求助

Fixing Composer/Laravel Setup Failures on Mac

Hey there, let’s work through this Laravel project setup issue you’re hitting. The timeout errors with Packagist and failed project creation in PhpStorm all point to network connectivity problems with Composer’s default repository. Here are actionable steps to resolve this:

1. Rule Out Basic Network & Proxy Issues

  • First, verify you can access Packagist directly: open https://packagist.org in your browser—if it won’t load, your network is blocked from reaching it.
  • If you’re using a VPN, proxy, or even a corporate network firewall, disable it temporarily. Many proxies interfere with Composer’s HTTPS requests.
  • Check Mac’s network settings (System Preferences > Network > Advanced > Proxies) to ensure no unintended proxy configurations are active.

2. Switch Composer to a Stable Mirror

The default Packagist server can be slow or unreachable from some regions. Switch to a domestic mirror (like Alibaba Cloud’s) for better stability:

# Set global Aliyun mirror
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

If you need to revert to the official source later:

composer config -g --unset repos.packagist

3. Fix PhpStorm’s Composer Configuration

PhpStorm might be using a local Composer instance with outdated or incorrect settings:

  • Open PhpStorm preferences (press Cmd + ,), navigate to Languages & Frameworks > PHP > Composer.
  • Confirm the Composer executable path is correct—on Mac, this is usually /usr/local/bin/composer or ~/.composer/vendor/bin/composer.
  • Enable Use global composer installation so PhpStorm uses the same Composer instance you configured in the terminal.
  • Try creating the Laravel project again, selecting the "Laravel" template from the new project menu.

4. Manual Laravel Installation via Installer

Using the official Laravel Installer is often more reliable than direct composer create-project:

  1. Install the installer globally:
    composer global require laravel/installer
    
  2. Ensure the installer’s path is in your system PATH:
    • Edit your shell config file (~/.zshrc for Zsh, ~/.bash_profile for Bash) and add:
      export PATH="$HOME/.composer/vendor/bin:$PATH"
      
    • Apply the changes with source ~/.zshrc (or your respective file).
  3. Navigate to your xampp/htdocs directory and create a project:
    laravel new your-project-name
    

5. Clear Composer Cache

Corrupted cache files can cause unexpected errors. Clear them with:

composer clear-cache

If none of these work, try switching to a mobile hotspot to rule out your home network’s restrictions. That often helps identify if the issue is with your local ISP.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 20:38:02