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

General Discussion

Torn between PHP and Rails

What is the advantages to PHP. What is the advantage Rails. Which is more popular? Which is growing more? What's more friendly to a beginner?

13 Answers

Chase MarLett
Chase MarLett
4,630 Points

Honestly, I haven't played with rails that much, but from my own personal experience PHP is easier and funner to learn. PHP has been around since the 90's but is still used on tons of sites- like Facebook. Rails is newer and probably looked upon more often, but PHP is like the Internet's universal language. Hope this helped :).

Dave Berning
Dave Berning
17,365 Points

I don't know much about Ruby other than I know you can make web applications. Same goes for PHP but PHP is used a lot more in web development; they both have their applications. PHP is used to make dynamic websites like an online shop or a large business website. I just finished a site for a company last week that used PHP. I used it because making a new navigation item, adding a file in the header, or adding copyright information in the footer is really easy. The webmaster in the future just needs to edit and upload one file instead of adding the same block of information in each section for every single page. It's very efficient when dealing with a large site.

In PHP you can also utilize the Unix Timecode and pull information with PHP to display the current year, month, date, day, etc. A few buddies of mine made a whole "Now Playing" widget for a college radio station website. This widget pulls a block of information and displayed it at a certain time. Every Thursday at 8PM it would display the radio that was currently on air.

As for which is easier to work with for an entry level developer, I do not know. Someone else might be able to answer that question. I just know PHP is a great and practical language to learn in the web field. My advise when learning PHP, get a basic understand of how php includes work. Once you understand how includes "include" data from other files then you understand the foundation of PHP. After that, you'll need to learn the syntax of creating variables and conditional statements and knowing when and how to use them.

NOTE: Wordpress is nothing but PHP.

Tim Knight
Tim Knight
28,888 Points

Hi Tristan,

You're going to get a lot of various responses for a question like this.

Like everyone, I'll try to speak to my experience. I've built web applications in both PHP and Rails. The difference between the two that you have to realize is that PHP is a language and Rails is framework in the Ruby language. Ruby has been around since the early 90s so it's been taken through it's paces. The framework of Rails was released in December of 2005, almost 10 years, so it too in terms of the Internet has been around for a lot time.

All of the dynamic support you have in PHP you have in Rails. Where Rails holds a lot of benefit is in the aspects of simplifying connectivity to your database and creating standard application functions (like sending email). With PHP you have configure your PDO connection manually and writing database code is all done manually in SQL. With Rails you use ActiveRecord, on ORM that allows you to speak to the database using Ruby code instead of SQL, so instead of writing something like:

$results =  $db->query("
    SELECT name, price, img, sku, paypal
    FROM products
    ORDER BY sku DESC
    LIMIT 4");

You'd write:

@products = Products.order(sku: :desc).limit(4);

Another place where PHP just doesn't do well is email. The mail function is pretty inconsistent and requires a lot of sendmail configuration to work. So instead there are large libraries like PHPMailer which itself requires a lot of code just to get working.

Yes, Wordpress is built on PHP so if you want to get really good at Wordpress, PHP is a great language. Facebook is based on PHP, but at this point they've written their own version called Hack (https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/).

PHP is well supported in a lot of sites so if you're just trying to put together a site with just a few pages... it's probably the best choice, however if you're trying to build something where users are logging in, storing data, and taking some kind of action I'd really look at Rails. The truth is both are great to know.

If you want a lot of the power Rails gives you while using PHP, checkout the Laravel framework (http://laravel.com/). Treehouse is currently working on a course that covers this PHP framework specifically.

I hope that helps.

Do you think rails could take over PHP? Which is better for a beginner? Could you build more with rails than PHP? Which do you see in the future? How are the courses at treehouse? Is the PHP course good? What about the Rails course? Should I learn font-end dev first? I know html good, but not CSS. Thanks for the responses.

Tim Knight
Tim Knight
28,888 Points

There's always going to be room for multiple languages, Rails isn't going to overtake PHP and PHP isn't going to overtake Rails. Each group will have it's favorite language, but that doesn't make either language any less viable. I don't see it has being able to build "more" with one over another... it's going to be more about, how well the language and framework works for your process. You're going to be able to write web sites either way. The future? Well, Rails has been a huge impact on the frameworks of today. Most modern PHP frameworks have some basis in their concepts that they pulled from Rails. When Rails introduced the ActiveRecord library it was kind of huge in the industry. Same goes with Microsoft's .NET (LINQ is somewhat based on the ActiveRecord pattern). So I see the future being languages that further simplify the process of making websites. The PHP course at Treehouse is pretty good. It'll take you though the basics and give you a general idea. The Rails stuff I think they are refreshing right now, but the courses found in the track are pretty new and great to work through. Honestly I'd just work through them both to see which you connect with the most. You might find going from HTML to PHP easier since PHP still follows a "page" method where Rails is more like programming an application using templates and views that are controlled by something called the Router.

Front-end skills aren't always required when you're working in a team. But if you're new to the field I'd recommend getting a solid basis on HTML, CSS, and JavaScript before moving to a back-end language like PHP or Rails. JavaScript will be a great introduction to programming concepts for you as well and all three of those topics are covered really well in the Treehouse courses.

Is there more ruby courses on treehouse because it's popular or it takes more to learn it?

Tim Knight
Tim Knight
28,888 Points

I think you're see a sign of it's popularity, not it's difficulty. That and Jason Seifer (the instructor) has been in the Rails community for a really long time and has done a lot for the community... so he has a lot to be able to teach and offer.

Tim Knight
Tim Knight
28,888 Points

Another place you might want to look is the free Rails Tutorial book online at http://www.railstutorial.org/book. It walks through building a Rails application that's like Twitter. It includes explaining how to test your code by writing tests and shows you all of the details on how database relationships are created and managed. Highly recommended as well.

Will treehouse give you enough knowledge to write your own rails applications. Do I really need front end knowledge?

Tim Knight
Tim Knight
28,888 Points

If you go through the track at http://teamtreehouse.com/tracks/rails-development you'll see there's an introduction to HTML and CSS as well as a course in JavaScript that they take you through before actually taking you into the Rails stuff. So yes, there's enough here to teach you what you need to get started to writing Rails applications. You just have to jump in. Later on you can always take more courses on the front-end stuff from the Web Design track. You're not locked into a track, you can do them all.

Tristan,

You're asking a common question, but asking this is wasting your time: "Do you think rails could take over PHP? Which is better for a beginner?"

The answer will always be: "it depends". It depends on what your goals are, what you're trying to do right now, what kind of work you want to do, what your skills and background are, etc. In other words--the context.

And know this for certain: once you've learned one language, learning another one is much faster and simpler. The third one and beyond? Even faster and simpler. In other words...it doesn't matter which language you start with. The important part is that you start, and finish--and then go make something with it, anything at all. You'll be in a new place, you'll see things more clearly, and you'll be better informed to see what your next steps are.

Trust me on this one, from my own hard experience and others. Just pick and go. Stop trying to optimize, or guess the "market", and so forth. Just go. Go. Ruby/Rails or PHP, doesn't matter. Python? Go. Commit.

Thanks for the comment. I'll take that to heart.