Manuals
RU EN

Server · 64

Composer on Windows Locally

Server 6 min read

Composer is needed when the project root contains composer.json and the script will not install without vendor/. Many ready Microscript archives already include dependencies or do not use Composer at all; then this manual can be closed. If the readme says composer install, continue.

On Windows, the main trap is that Composer must see the same PHP 8 as your local server, not a random php from PATH left by an old XAMPP.

PHP in PATH

Find where the php.exe of MicroServer or OpenServer is located. Add that directory to the user PATH or call the full path. Check in a new cmd/PowerShell:

php -v
php -m

You should see an 8.x branch and modules from the requirements. If php is not found, Composer-Setup can also bind to the wrong interpreter.

Installing Composer

  1. Download the official Composer-Setup for Windows.
  2. Specify the path to the required php.exe.
  3. Wait for installation and open a new terminal.
  4. composer -V should show a version.

Alternative without the installer: put composer.phar next to the project and run php composer.phar install. For local development, the installer is more convenient.

install in the project

cd D:\MicroServer\www\project.loc
composer install

For a production-like install without dev packages:

composer install --no-dev --optimize-autoloader

The vendor/ directory and autoloading will appear. The host document root should not accidentally serve unnecessary content from vendor; normally public PHP entry points are not placed there.

Common errors

  • php is not recognized as a command: PATH.
  • Your requirements could not be resolved: PHP is lower than the constraint in composer.json; update PHP.
  • Missing zip/openssl/mbstring: enable the extensions for PHP.
  • Proxy or antivirus blocks packagist: use another network or mirror temporarily.
  • memory exhausted: use COMPOSER_MEMORY_LIMIT=-1 or raise memory_limit.

Do not commit secrets here. Keep auth.json with tokens out of public copies.

vendor in backups. Sometimes including vendor in a migration is easier than running composer on weak shared hosting without SSH. On a VDS with SSH, composer install on the server is normal. See migration.

Connection with the local server

Project host: *.loc. Stack: MicroServer. Denver alternative: here. After install, open the site and check that autoloading works; otherwise 500 with Class not found: 500 error.

On VDS

The same commands run under the Linux site user. PHP-CLI must be the same version as FPM. Without SSH on shared hosting, Composer is often unavailable, so dependencies must arrive in the archive.

Server choice: VDS, root: VPS with root. Full product installation: installation.

Updating packages

Do not run composer update on production without a reason; it can move to major versions and break the script. Update according to the product release instructions. Experiment locally on a database copy: backup before updates.

Which PHP Composer sees

A common Windows trap: PATH contains C:\xampp\php or old OpenServer, while the site in MicroServer runs on another php.exe. Composer installs packages according to the CLI platform PHP. Then composer install succeeds, but the web side complains about syntax or a missing module.

Check:

where php
php -v
composer config --list | findstr php

If where shows the wrong path, fix PATH or call:

C:\path\to\php.exe C:\ProgramData\ComposerSetup\bin\composer.phar install

Find the MicroServer PHP path in the server installation directory. Stack documentation: local server.

composer.json and lock

composer.lock pins versions. On production and locally, install from lock with install, not update. Otherwise "works on my machine" may use different minor library versions than the VDS.

If the product archive has json but no lock, install still creates a lock. Keep it for repeatable deployments. Do not edit vendor by hand; the next install overwrites it.

SSL and packagist errors

Corporate Windows environments sometimes break SSL to repo.packagist.org. Symptom: curl error 60 / certificate problem. Fix by updating the PHP CA bundle or temporarily using another network, not by disabling verify-peer globally forever.

Antivirus with https scanning can also break Composer. If the error floats, exclude the project directory and php.exe during dependency installation.

When Composer is not needed

Many Microscript deliveries are "unpack, create database, open installer". No composer.json means do not install Composer just for show. On shared hosting without SSH, the extra tool is useless anyway.

If vendor is already in the package, do not run install over it without a reason. Exception: readme explicitly says to refresh dependencies after switching to PHP 8.2.

Linux permissions and vendor after copying from Windows

After moving a Windows archive to VDS, watch line endings and permissions. vendor must be readable by PHP-FPM. Executable files in vendor/bin sometimes lose +x; for web scripts this is rarely critical, for CLI tools it may be.

Full migration: script migration. If deployment gives Class not found, autoload is missing or vendor was not uploaded: 500 error.

Practical local order

  1. Create host project.loc: vhost.
  2. Unpack the script archive.
  3. Check php -v for the same 8.x branch.
  4. If composer.json exists, run composer install.
  5. Create the database: phpMyAdmin.
  6. Run the installer: installation.

On a root VDS, the order is the same, only the php binary and Linux PATH differ: VPS with root, VDS. If you came looking for old Denver with Composer, see Denver PHP 8.

If composer install downloaded packages but the site still says Class not found, check that document root points to the directory containing vendor and that index/bootstrap requires autoload. Sometimes the product archive puts the entry point in public/, while you open the parent directory. Locally this is fixed by the correct host folder: *.loc. Do not delete vendor "for cleanliness" before uploading to shared hosting without SSH; you may not be able to rebuild it. Better include it in the archive during migration. Before experiments with update on a database copy: backup, PHP requirements: requirements.

FAQ

Composer on windows locally?

Composer installs script packages locally the same way it does on a VDS.

How long does “Composer on Windows Locally” take?

About 6 minutes to read. In practice it depends on your hosting and database setup.

Do I need a dedicated server?

For most scripts, shared hosting or a VDS with PHP and MySQL is enough. See the VDS section and PHP/MySQL requirements.

Denwer php 8 free download?

See the related manual for this query. denwer php 8 free download

Windows local server php 8 mysql?

See the related manual for this query. windows local server php 8 mysql

Section
Denwer and local server

A Windows local stack for debugging scripts before you deploy to a VDS.