Cannot install Composer with XAMPP on Windows
When attempting to install Composer on a Windows machine running XAMPP, you may encounter an error stating that the php.exe file did not run correctly. The specific message often points to a configuration issue in php.ini, specifically regarding the extension_dir or missing DLL files. In the scenario where this occurs, the installer fails with warnings like "Unable to load dynamic library 'C:\xampp\php\ext\php_oci8_12c.dll' - The specified module could not be found."
The core issue here is a mismatch between the PHP extensions you have enabled in your configuration file and the actual files present on your system. The error log explicitly shows that Composer (or rather, the underlying CLI PHP process) is trying to load php_oci8_12c.dll and php_pdo_oci.dll. These libraries are designed for Oracle database connectivity. If these DLLs are not installed, or if they exist in a directory different from what php.ini expects, the startup fails immediately, preventing Composer from initializing.
The provided source material indicates that the user has already uncommented the lines in php.ini corresponding to these extensions:
extension=php_oci8_12c.dll
extension=php_pdo_oci.dll
However, the screenshots of the /php/ext directory suggest that while some files are present, the specific Oracle DLLs required might be missing or located in a path that php.ini is not referencing correctly. On Windows, the order of extension loading matters, but the most critical factor is simply existence and path alignment.
To resolve this, you must first determine if these extensions are actually needed for your project. If you are building a standard Laravel application or a generic PHP CLI tool without Oracle connectivity, these extensions are unnecessary baggage. The quickest fix is to comment them out in php.ini:
;extension=php_oci8_12c.dll
;extension=php_pdo_oci.dll
After saving the file, restart your XAMPP services and attempt the Composer installation again. If the error persists despite commenting these specific lines out, you may have other extensions causing conflicts or extension_dir misconfigurations. You should verify that extension_dir in php.ini points exactly to C:\xampp\php\ext. Sometimes, XAMPP installations include legacy extensions that are no longer compatible with the current PHP version bundled with it.
If you require specific extensions, ensure that the DLL file exists in the directory specified by extension_dir. If the file is missing, you cannot simply comment it out if it was causing a fatal error at startup; however, usually, commenting it out suppresses the warning and allows execution to continue. If the PHP version bundled with XAMPP is outdated (e.g., stuck on an older 7.x release that expects 12c Oracle drivers which might not match your system architecture), upgrading PHP via XAMPP Update or switching to a different PHP distribution like Laragon or WAMP with a newer version might be necessary.
For developers looking for a more streamlined environment where these configuration headaches are minimized, consider the LaravelCompany Laragon setup. It is designed specifically for Windows developers and handles PHP versions, extensions, and Composer integration out of the box, significantly reducing the friction associated with manual php.ini tweaking on XAMPP.
Ultimately, debugging extension loading errors requires a disciplined approach: verify the extension_dir, check the physical existence of every DLL referenced in php.ini, and strip down non-essential extensions until the CLI runs cleanly. Once the PHP interpreter can start without warnings regarding missing modules, Composer will install successfully.