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

Development Tools Setup Your Local Development Environment

Not so much a question, more of a comment.

Although MAMP is "easy", it doesn't mean its the best solution.

The disadvantage for using this method is that you're installing stuff that you already have installed. This can cause problems when - for example - you want to use PHP using the command-line. This will trigger the built-in PHP version by default instead of the one bundled with MAMP. If these are different the results can be unexpected. There's also been issues when the OS gets updated, MAMP can bug out.

I would recommend using the default OSX versions of both Apache & PHP. After you got it all up and running the first time you really don't need a control panel or anything.

Using a set up similar to http://github.com/kiriaze/mac-dev-env (*shameless plug, OSX dependent although you can find similar repos for Windows, as well as .dotfiles etc.) or Vagrant (if you want silo'd systems, especially VVV for WordPress projects) is my recommendation. Not only are these methods more professional and industry standard, but you will learn much more about systems ( specifically yours ) and will be able to apply these learnings towards other setups like node/express etc.

Depending on a 3rd party 1-click solution has many caveats, and having to pay for this "simplicity" might benefit newcomers, but honestly its worth investing the time to learn how to use the native functionality of your systems rather than learning how to use said 3rd party program and all the baggage that comes with ( bugs/support/$$$ ).

Also one last note on Vagrant(PuPHPet, and the like), definitely invest time exploring this as it sets up the same environment for local/production/etc across the board - ensuring that everything works as expected - no more of "Well, it works on my computer..".

Just my 2 cents =)

jeremy rackley
jeremy rackley
22,336 Points

+1 for Vagrant I use Vagrant everyday at work for local Drupal Environments. Another option for basic easy local development would be to use Docker, however I personally prefer Vagrant over docker and using robo as a task runner. Mamp is good for someone just getting started, but as stated can be very frustrating when you start to run into issues.

I have checked a link you provided and I understand some of that stuff but something strange happened few days ago. I was trying install everything through Terminal and my Mac gone wild. Apps didn't work, they just jumped and didn't open. I needed to reinstall whole OS... I did that and now I am scared I will screw my Yosemite again if I do this manually. Can you recommend some reading on local PHP and Apache and how to install everything correctly? I really want to learn "pro way" and there are so many tuts but they never really explain in depth, just c/p this in your terminal and that's it.

jeremy rackley
jeremy rackley
22,336 Points

@Antonija Pek: This is a pretty decent tut on how to get up and running locally. It uses macports, which just a personal opinion but I tend to like better. http://www.web2works.co.uk/blog2works/install-php-5-apache-2-mysql-5-on-mac-os-x-via-macports/

I have installed the macports but I still have problems with apache. I created folder Sites in /Users/myname/ but when I type in URL "localhost" it looks like it is still in default folder. I followed this tut http://ole.michelsen.dk/blog/setup-local-web-server-apache-php-osx-yosemite.html and when I try to access http://localhost/myname/phpinfo.php it says Not found. I'm lost here. I can't find tutorial that works for me.

4 Answers

Alena Holligan
STAFF
Alena Holligan
Treehouse Teacher

First off, if you already have a dev environment or prefer one way over the other, by all means use that. This workshop is meant to provide beginners with a simple means to run their PHP sites directly on their machines.

Second, thank you all for helping each other, you are what make our community awesome! :)

I spent quite a bit of time when considering what to show people since there are many great options that may be a better choice depending on your personal need. The goal of this workshop is to get complete beginners up and running as soon as possible so they can learn PHP without having to learn anything else first. Here are some things I considered when deciding what to use:

  1. if you're on a Mac, setting up a local dev environment directly on your machine is fairly strait forward, PHP and Apache are install right out of the box, so you just may want to upgrade those. Then that just leaves a database like MySQL which isn't too tough to install. There are some easy to follow tutorials online if you just do a google search. This CAN BE a good option for the speed, as it CAN have the smallest impact on your computer. Windows on the other hand.... I just wont go there :) a few things to think about
    • It's not as easy for beginners and you'll have quite a bit of command line work to do.
    • If you don't actually shut down apache and mysql, you're actually bogging down your computer ALL THE TIME instead of when you want to test out your site.
    • If you mess something up, it's not easy to revert. With MAMP, you just delete the folder (or uninstall MAMP Pro) and you're done. The support is what really makes this hard for us to justify at Treehouse.
  2. There are quite a few *AMP packages available for both Windows and Mac, including Bitnami which is similar to xampp and I would choose it over xampp specifically for being able to test out PHP 7 and HHVM, so if that interests you, please check out bitnami.
  3. If you're going to work for a large company they will probably have some sort of virtual image for you to use that matches their production environment. This is probably done using something like docker or vagrant. This is more complicated and more to learn just to get started with PHP. Since this IS something that can help you in your career, we will probably cover this at some point either as a workshop, blog post or both.

Some of the main reasons I chose MAMP

  1. MAMP itself is free and you can easily use it without having to upgrade to Pro.
  2. With MAMP Pro you can access everything in one place, including:
    • Setting up virtual hosts
    • Switching to multiple versions of PHP for testing. This can be extremely helpful when testing out an upgrade or new server, or testing things like WordPress plugins on multiple versions. But it can also get complicated, buggy and easily messed up.

I hope this helps to clarify things a little bit for you. Here at Treehouse we work hard to give you the best experience we can, so thank you for your feedback and stay tuned for more :) For now, like I said before, feel free to use whatever system works for you, just PLEASE TEST YOUR CODE BEFORE YOU DEPLOY TO PRODUCTION :)

Some good points Alena Holligan ! Wasn't aware of bitnami - very nice!

jeremy rackley Totally forgot about docker, real awesome and tying it with Dokku or Rancher(more for production tho) extends it nicely.

Antonija Pek Thats quite strange, although I do mention that it assumes you're on a fresh install of Yosemite, and to also read through the script first before using it and even cherry picking what you'd like if you don't want to install everything. If you'd like to place an issue on github i could further help you out. It's quite strange that you mention your apps no longer work, did you follow the readme and have the right permissions setup? Also, to the note of your last post, did you follow this here: https://github.com/kiriaze/mac-dev-env#local-osx-yosemite-apache-setup ?

Perhaps the issue might simply be you have to restart apache, type apachectl restart within terminal, you might have to use sudo before this depending on your permissions, so - sudo apachectl restart, then try reloading just localhost for now. Sorry I didnt get back to you guys sooner, my email notifications must have been turned off. Let me know if that helps Antonija!

Hi Constantine Kiriaze! Somehow I managed to get it all to work one hour ago. It is the first time I am using composer and anything like that so I somehow managed to install that as well and include in Slim project although I don't quite understand all the concepts and syntax. I am watching PHP videos now, they are so confusing...

Also Antonija Pek forgot to mention, my setup is targeting a different directory than described in the article you posted, whereas they target the /Sites directory, I target a newly created /Localhost directory.

Glad you got it to work Antonija Pek ! Package managers are awesome! Composer for php, Bower for front end, and NPM are my main go-tos. Slims real nice, have you looked into Larvels Lumen at all? Anyways, keep on it! =)

I looked into Laravel but it is too advanced for now, I have to learn how to make CMS in it's simplest form, with no frameworks. After I understand that, I will learn some framework.