Current Location: Home> Latest Articles> A Step-by-Step Guide to Installing ThinkPHP5 with Composer on Windows

A Step-by-Step Guide to Installing ThinkPHP5 with Composer on Windows

gitbox 2025-07-26

How to Install ThinkPHP5 Using Composer on Windows

Composer is a widely used dependency management tool in the PHP ecosystem, significantly simplifying the installation and management of the ThinkPHP5 framework. This article walks you through the process of installing and configuring ThinkPHP5 on a Windows operating system using Composer.

Installing Composer

First, you need to install Composer on your computer. Visit the official Composer website (https://getcomposer.org) to download the Windows installer, then follow the instructions to complete the installation. After installation, verify the success by running the following command in your command prompt:

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

If the version information appears, Composer has been installed and configured correctly.

Creating a ThinkPHP5 Project

Once Composer is installed, you can create a ThinkPHP5 project. Follow these steps:

Open Command Prompt

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

Navigate to the Project Directory

Use the cd command to switch to the directory where you want to store your ThinkPHP5 project. For example, to create the project under the www folder on your D drive, run:

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

Run the Create Project Command

Execute the following Composer command to install ThinkPHP5:

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

This command will automatically download the latest version of ThinkPHP5 and its dependencies.

Configure Local Web Server

After creating the project, configure your local web server to run the application. For Apache, set the root directory to point to the public directory inside your new project. Open the Apache configuration file and locate the following line:

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

Change it to:

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

Save the changes and restart Apache to apply the configuration.

Test Access

Open your browser and navigate to http://localhost. If the ThinkPHP5 welcome page appears, your installation and configuration were successful.

Conclusion

By following these steps, you have successfully installed and run ThinkPHP5 on a Windows system using Composer. Composer simplifies dependency management and speeds up project setup. Ensure PHP and your web server are properly installed and environment variables are set to guarantee a smooth development experience.