Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Dependency Management Introducing Composer

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Installing Composer Locally on Mac OSX 10

Hi,

I have completed the course in Workspaces and even though I apparently have the correct code (according to other students) I have been unable to load the site when attempting to preview it.

I have started a new site folder in htdocs on my locally installed MAMP server. How do I install Composer locally?

I am going to attempt to start over from scratch.

Thanks!

8 Answers

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

I have just installed (finally...lol) composer to my local directory in htdocs by typing this into the console:

cd /applications/mamp/htdocs/composerphpslim (my project/folder name)

...then this:

curl -sS https://getcomposer.org/installer | php

The console returned this:

Composer successfully installed to: /Applications/MAMP/htdocs/composerphpslim/composer.phar Use it: php composer.phar


So far so good I think....

Once you have composer installed globally, then you can run composer init. I know this is covered in the course. Answer the required questions (some are not required) and it will initialize the project. This video goes step by step through the init process and has you install monolog.

Hello Ted, Thanks for your reply. I did install composer globally and I tried to run composer init, it worked fine but composer.json file was not installed in my specific project folder, this is where I am getting stucked.

I am trying to install the composer in my htdocs folder to run it with the MAMP. Please advise how should I define the folder in the terminal so that it knows where to install the composer file.

thanks,

First, I recommend that you install your projects in subfolders in the htdocs folder. That way you can work on multiple projects at the same time.

Open your command line tool and enter change directory to the folder with the project. The command would look something like this: cd /opt/lampp/htdocs/project_folder

Then run composer init

Answer the questions and it should create the Json file in the root of the project.

The path is what is on my Linux machine for the XAMPP install. You need to use your own path. I don't know what that is.

Here is the best installation guide I found on Github ! Worked perfect for me !

https://gist.github.com/kkirsche/5710272

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Thanks Ted, but I don't even know where to start to run the code (in my project directory or directly in my terminal) or what the difference between running it locally or running it globally means.

Are there any tutorials on Treehouse for this that you know of?

Thanks again:-)

I think I did a global installation. Just copy and paste the command given in the link to your terminal and let it run. I am using Linux Mint and it may have been in my package manager. I don't remember now what I did.

I found a way to install it on the Mac, you just have to copy paste the things for global installation. But the place where i really got stuck is how to use it Locally. I couldn't find a way to link the terminal with the folder.