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

Windows环境下通过Composer安装Laravel项目报错求助

Hey Martin, let's break down what's going wrong here and fix it step by step!

What's Causing the Errors?

You've run into two separate issues, both tied to misusing the Composer global directory:

  1. Laravel Installer Permission Error: You manually created the C:\Users\marti\AppData\Roaming\Composer\vendor\bin directory, but Windows restricts write permissions for manually created folders in the AppData system directory. Composer can't write the Laravel Installer files here.
  2. create-project Config File Error: You tried to initialize a Laravel project directly inside C:\Users\marti\AppData\Roaming\Composer\vendor\bin—this directory is for global Composer tools (like the Laravel Installer), not your actual Laravel projects. Composer expects a valid project directory with a composer.json file, which doesn't exist here.

Step 1: Fix the Composer Global Bin Directory

Let's reset the global bin directory to let Composer handle it properly:

  • First, delete the manually created C:\Users\marti\AppData\Roaming\Composer\vendor\bin folder. Composer will automatically generate this folder with correct permissions later.
  • Open Command Prompt as an administrator, then run this command to install the Laravel Installer globally:
    composer global require laravel/installer
    
    Composer will now create the vendor\bin directory automatically and set the right permissions for it.
  • Double-check that your Windows Path environment variable still includes C:\Users\marti\AppData\Roaming\Composer\vendor\bin (you already set this earlier, so this is just a quick verification step).

Step 2: Create Your Laravel Project Correctly

You need to create your project in a user-controlled folder (not the Composer system directory). Here's how to do it with both methods:

Using Laravel Installer

Run this command to create a project in your desired location (replace C:\Projects\my-laravel-app with your actual preferred path):

laravel new C:\Projects\my-laravel-app

Or if you're already in your projects folder via Command Prompt, just run:

laravel new my-laravel-app

Using composer create-project

Same idea—point the command to a user folder:

composer create-project laravel/laravel C:\Projects\my-laravel-app

Or from your projects directory:

composer create-project laravel/laravel my-laravel-app

That should get your Laravel project up and running without permission or config errors!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 11:47:29