This content originally appeared on DEV Community and was authored by Alonzo
If you're using PHP or any PHP framework/library for the first time, you've probably noticed when you tried to use composer to create a project that you don't have certain extensions. You may have tried to go to composer to install these extensions, only to find out that this isn't working. Here's how to solve that problem.
You may be surprised to find out that these extensions are already installed, but just are not enabled. To enable these, you must go to C:\tools\php80_ in your file explorer. Next, you need to look for the php.ini file. It may be hard to find this because the .ini file extension is not shown after PHP. To locate this file, look for the icon that has the Configuration settings type. Next, open it using your code editor/text editor/IDE. Next search for a long list of extensions that begin with _;extension. The ; comments out a single line, so look for the extensions that begin with ;extension and delete the ;. This will enable the extension. You are now ready to use the PHP framework/library of your choice.
While developing your web app, you may try to install a package from composer, only to find that an extension that is not already in the php.ini file. How can you fix this?
Adding Extensions
To add extensions, you need to go to http://pecl.php.net/ to find the extension you need. (I'm using MongoDB as an example) When you find an extension, find the right version and click on dll. Again, look for the version compatible with your version of PHP, and download the ** non-threaded** file if you're not using apache. After that, extract the file and find the dll file. Next copy the file into C:\tools\php80\ext. You can then add the entry for the new extension in php.ini like the other extensions (for example, to add MongoDB, you would type extension=mongodb in alphabetical order of extensions unless stated otherwise). With that done, you can then install the package you need.
This content originally appeared on DEV Community and was authored by Alonzo
Alonzo | Sciencx (2021-07-19T19:28:12+00:00) Adding/Enabling Extensions in PHP using Windows. Retrieved from https://www.scien.cx/2021/07/19/adding-enabling-extensions-in-php-using-windows/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.