Trying to install Laravel using composer and it says "the requested PHP extension fileinfo is missing from your system"
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
# Solving the Composer Headache: Why Laravel Installation Fails Due to Missing PHP Extensions
If you’ve ever tried to set up a new Laravel project or install dependencies using Composer only to be met with cryptic errors like, "the requested PHP extension fileinfo is missing from your system," you know the frustration. It stops the development flow dead in its tracks. As a senior developer, I can tell you that this error isn't about Laravel itself; it’s a fundamental issue with your underlying PHP environment configuration.
This post will dive deep into why this happens, and provide a comprehensive, step-by-step guide on how to resolve missing PHP extensions so you can get back to building fantastic applications.
## Understanding the Root Cause: Dependencies vs. Environment
The error message you see during a Composer installation is not an error from the Laravel package; it's an error generated by the dependency resolution process. When packages like `league/flysystem` or `league/mime-type-detection` are installed, they rely on specific functionalities provided by core PHP extensions. In this case, they require the `fileinfo` extension to be present and enabled for Composer to proceed with installing those libraries.
The problem isn't that Laravel is broken; the problem is that your PHP installation, while capable of running basic scripts, is missing necessary modules required by modern third-party packages. This often happens with minimal PHP installations or environments like XAMPP where extensions are disabled by default.
## Step 1: Enabling the Missing Extension
The solution lies in ensuring that the specific PHP extension (`fileinfo`) is properly compiled and enabled within your PHP configuration files. The location of these files depends entirely on how you installed PHP (e.g., using XAMPP, MAMP, or a native Linux package).
### For XAMPP/Windows Users
If you are using a local server stack like XAMPP, the configuration is typically managed through `php.ini`.
1. **Locate `php.ini`:** Navigate to your PHP installation directory (e.g., `C:\xampp\php\php.ini`).
2. **Edit the File:** Open this file using a text editor.
3. **Uncomment the Extension:** Search for the line referencing `fileinfo`. It will likely be commented out by a semicolon (`;`). Remove the semicolon to enable it:
```ini
;extension=fileinfo
extension=fileinfo
```
4. **Save and Restart:** Save the `php.ini` file. Crucially, you must restart your Apache or PHP service for these changes to take effect.
### For Linux/Debian Users (Using CLI)
On most Linux distributions, extensions are installed via the package manager. If a module is missing, you need to install the corresponding package.
```bash
# Update your package list
sudo apt update
# Install the fileinfo extension package
sudo apt install php-fileinfo
```
After installation, restarting the web server service (if applicable) or running `php --ini` in your terminal should confirm that the extension is now recognized by the CLI.
## Step 2: Verification and Best Practices
Once you have enabled the extension, run a quick check to ensure Composer can see it:
```bash
php -m
```
This command lists all loaded modules. If `fileinfo` appears in the output, you are good to go!
When developing with frameworks like Laravel, maintaining a robust and correctly configured environment is paramount. As we strive for high-quality, maintainable codebases, ensuring that the foundational tools—like PHP