Rails for PHP Developers (Pragmatic Programmers)

Rails for PHP Developers (Pragmatic Programmers)

Derek DeVries, Mike Naberezny

Language: English

Pages: 430

ISBN: 1934356042

Format: PDF / Kindle (mobi) / ePub


As a PHP developer, you have some great tools for developing web applications. Ruby on Rails is another key tool to add to your web development toolbox. Rails is a high-level web development framework that emphasizes high productivity and clean code. However, the Ruby language and Rails framework take a different approach from the way many PHP developers write applications.

Ruby lies at the foundation of Rails, and we'll teach you the Ruby language from the beginning by building on your existing foundation of PHP. We'll explore Ruby through parallel code examples that illustrate the differences between the languages, and help you understand the Ruby idioms and how they differ from popular PHP code and style.

You'll then learn the Rails framework by iteratively building a complete application, starting from the home page through to a finished product. Along the way, you'll build your skills as a Rails developer by learning the Rails fundamentals such as MVC structure, domain modeling, and testing.

In addition to serving as a guide to learning both Ruby and Rails from a PHP developer's perspective, this book includes two extensive reference chapters. They map the most common PHP tasks to their equivalents in the Ruby and Rails world, giving you at-a-glance information that you'll refer to often.

Learning Rails 3

Guide to Web Development with Java: Understanding Website Creation

Dependency Injection with AngularJS

Web Design: Best Portfolios (Icons)

Python Web Development with Django

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

User def admin=(admin) @admin = admin end def admin? @admin || false end end joe = User.new joe.admin = true puts joe.admin? # => true The exclamation point is often used to symbolize that the method per- forms an operation that is destructive or changes the receiving object. You’ll probably notice that many built-in Ruby methods have a corre- sponding method that ends in an exclamation point. Ruby Download php_to_ruby_language/ruby/functions/functions_bang.rb foo = [2, 1, 3] #

PHP to Rails Reference 371 13.1 Templates . . . . . . . . . . . . . . . . . . . . . . . . . . 371 13.2 $_GET/$_POST . . . . . . . . . . . . . . . . . . . . . . . 372 13.3 $_FILES . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 13.4 $_SERVER . . . . . . . . . . . . . . . . . . . . . . . . . . 376 13.5 Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 13.6 Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . 378 13.7 Headers and Redirection . .

syntax. Before we start coding, let’s go over some of the Rails conventions that will inform the decisions we make as we write our applications. 1.3 Opinionated Software The Ruby and Rails culture is quite different from that in PHP, and this is reflected in both the code and the community. Rails is consid- ered opinionated code, and it’s important to understand where and why Rails expects you to follow certain coding principles and conventions. Rails code has been heavily influenced by

http://tucsonrails.org:8000/ ProxyPassReverse / http://tucsonrails.org:8000 ProxyPreserveHost on current> sudo apachectl restart This gets us up and running, but there is a chance you’ll need to run additional Mongrel servers for your application as it grows. Rails code is not thread safe, and high-traffic websites usually need more con- currency than is allowed by a single Mongrel. Since Mongrel uses one thread per request, more traffic means we need to increase the

discussed in Chapter 13, PHP to Rails Reference, on page 371. Scope You’ll find that the basic scoping of variables in Ruby is almost identical to that in PHP. Top-level scoped variables are available within control structures, but not functions or methods. PHP Download php_to_ruby_language/php/variables/scope.php // local to the top-level $a = 1; VARIABLES 288 // also top-level scope if (true) { $a = 2; print $a; // => 2 } print $a; // => 2 Ruby Download

Download sample

Download