Current Location: Home> Latest Articles> Quick Guide to Installing ThinkPHP5 with Composer on Windows

Quick Guide to Installing ThinkPHP5 with Composer on Windows

gitbox 2025-07-26

Advantages of Installing ThinkPHP5 with Composer on Windows

Using Composer to install ThinkPHP5 is an efficient solution for Windows users to set up their development environment. Composer, as a PHP dependency management tool, allows easy installation and maintenance of ThinkPHP5 and its related components. This article explains how to complete the installation and configuration of ThinkPHP5 using Composer on a Windows system.

Install Composer

First, you need to install Composer. Visit the official site (https://getcomposer.org) to download the installer suitable for your Windows version. Run the installer and follow the instructions to complete the setup.

After installation, open the command prompt and run the following command to verify Composer installation:

<span class="fun">composer --version</span>

If the command returns the Composer version number, the installation is successful.

Create a ThinkPHP5 Project

Open the Command Line

On Windows, press Win+R, type “cmd,” and press Enter to open the command prompt.

Navigate to the Target Directory

Use the cd command to change to the directory where you want to create your project. For example, if your project is under the D drive’s www folder, run:

<span class="fun">cd D:\www</span>

Run the Project Creation Command

Once in the target directory, create the ThinkPHP5 project using Composer:

<span class="fun">composer create-project topthink/think</span>

This command downloads and installs ThinkPHP5 and its dependencies from Packagist automatically.

Configure the Local Server

After creating the project, configure your local server to run the application. For example, with Apache, point the root directory to the public folder within your ThinkPHP5 project.

Open the Apache configuration file (usually in the conf folder of your installation directory) and find this line:

<span class="fun">DocumentRoot "${INSTALL_DIR}/htdocs"</span>

Change it to:

<span class="fun">DocumentRoot "D:/www/thinkphp5/public"</span>

Save the file and restart the Apache server to apply the changes.

Test the Application

Open your browser and enter http://localhost. If configured correctly, you will see the ThinkPHP5 welcome page, indicating a successful installation.

Summary

Following these steps, you can quickly install and deploy ThinkPHP5 on a Windows environment using Composer. This method simplifies dependency management and project setup, enhancing development efficiency.

Reminder: Ensure PHP and Apache are installed and configured properly before starting, and system environment variables are set correctly.