How to Setup Composer with PHP on Windows
What is Composer?
Composer is a modern tool for dependency management in PHP, like a package manager. as It allows to easily install PHP packages and even frameworks etc..
What Will I Learn?
- Configure PHP 7
- Install Composer
- Basic Usage
Requirements
- Windows 10,8.1,7 (x64)
- Text Editor (Notepad++ eg.)
- PHP 5 or above
- Visual C++ Redistributable for Visual Studio 2012
- Visual C++ Redistributable for Visual Studio 2017
Difficulty
- Basic
Setup Composer
Composer requires the PHP OpenSSL
extension to be enabled, so let's enable it in your php path C:\PHP\php.ini
Use your text editor's search function to search for extension=openssl
, there should already be a commented line for it
just uncomment
that line.
Make sure you've set the path of extensions.
Search for ; extension_dir = "ext"
Then uncomment it and set the path of ext folder.
for example: extension_dir = "C:\php\php5\ext"
The installer will download composer for you and set up your PATH environment variable so you can simply call composer
from any directory.
Download and then run [Composer-Setup.exe] (https://getcomposer.org/Composer-Setup.exe) - it will install the latest version of composer whenever it is executed.
Install Composer
- Developer Mode means that it will automatically select the php path if you have more than one php version and you prefer a specific version just uncheck it.
Follow the instructions, when prompted for the path to PHP, browse to your php path and select php.exe
.
Then follow the rest of instructions of the setup process. Until you finish.
That's it, Composer is now installed globally and it can be used from anywhere. you can try it out, just open a new command prompt and type composer
.
Check Composer Version
Open command prompt then type composer -v
Note:
you may need to restart the system to use composer globally.
Basic Usage
To start using Composer in your project, all you need is a Create a new file composer.json
that you've been created file. This file describes the dependencies of your project. also it can contain other meta data.
Create a new file composer.json
that you've been created in a directory, that directory is a package. When you add a require to a project, you are making a package that depends on other packages.
For example I want I want to install Laravel framework
So So I will create new project folder and call it laravel
Then Then Open it. Then Create a new file composer.js
{
"require": {
"laravel/laravel": "5.0.*"
}
}
That's it.
Previous Tutorials
- Setup your own Apache MariaDB PHP phpMyAdmin on Windows!
- Configure PHP 7 after installing with Apache on windows
- Configure PHP 5 after installing with Apache on windows
- How to use multiple PHP versions with Apache on Windows
Images has been taken/created by @Jinzo for an open source project.
Posted on Utopian.io - Rewarding Open Source Contributors
Great post.
This post has received a 0.18 % upvote from @drotto thanks to: @jinzo.
Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.
You can contact us on Discord.
[utopian-moderator]
That isn't correct at all.
even the picture you've made the text isn't matching with my post.
Thank you.