Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP looking for ext folder on wrong drive

I have installed PHP 7 on windows 10 to my E: drive so I can try out composer.

When I try to run composer I get an error that it can't find the extensions I enabled but I can see it is looking in C:\php\ext and not E:\php\ext.

I looked in php.ini but couldn't see whre to set the path of the root installation.

Does it always default to C:? How do I tell it to look in E:?

like image 261
Guerrilla Avatar asked Jul 27 '16 20:07

Guerrilla


People also ask

Where is PHP ext directory?

So after installation of PHP the best way to identify the extension directory is to open php info file and check for all the settings. In the php info display it will be written where the extension file of the system is stored. It is also known as extension_dir .

What is PHP extension directory?

extension_dir = <PATH TO EXTENSIONS>: The extension_dir points to the directory where the PHP extensions are stored. The path can be fully qualified (for example, C:\PHP\ext ) or relative (for example, . \ext). Extensions that are specified lower in the Php. ini file are located in the extension_dir.

How to compile a PHP extension on Windows?

To compile PHP extensions on Windows, extract the extension's source code folder into the ext folder of your PHP source directory. Then, rebuild the configure script by running buildconf --force and re-compile PHP using the appropriate flags to enable the extension.


1 Answers

For some reason, PHP for Windows is hardwired to look for extensions in C:\php\ext no matter where you installed it. But there's a simple fix for this.

In your php.ini, look for the line extension_dir =. If it's disabled (as a comment), enable it.

You only need to mention the name of the folder where the extensions reside if this folder is inside your PHP installation folder. An absolute path is not necessary.

extension_dir = "ext"

Open a Command Prompt and run php -a to check if PHP complains about missing extensions. If not, you're doing good.

like image 125
ADTC Avatar answered Oct 18 '22 06:10

ADTC