Getting Started with Composer | Day 15

If you are reading this post, it means you’ve decided you need Composer for your project. I’ll give you 5 basic steps to help you get started and have composer running. This steps are for windows users.

###Step 1 Download and install [composer setup](
and follow the installation process. It’s really straight forward. Honest!

###Step 2
Open your terminal to check if composer is there

Composer -V
You should get this back

![Composer version 1.0](/content/images/2015/05/Capture9-1.PNG)

###Step 3
Go to your project directory and create a new file called composer.json and add the following lines of code in it. It asks, composer to include the twitter api for php in our project (I probably mentioned I was working on that this week)

“require”: {
“j7mbo/twitter-api-php”: “dev-master”

###Step 4
Go back to your terminal and run this in your project directory. This installs the twitter api.

composer install

You will notice that there is a new folder called ‘vendor’ in your directory. In there is where Composer adds all your dependencies

###Step 5
It’s all done in 4 steps. If you need to add another external dependency for your project, add it to your composer.json file. Let’s tell composer to install all the dependencies for phpmailer.

“require”: {
“j7mbo/twitter-api-php”: “dev-master”,
“phpmailer/phpmailer”: “5.2.*”

Finally do a composer update, to update your ‘vendor’

composer update

In your index.php file add this at the top

Leave a Reply

Your email address will not be published. Required fields are marked *