Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
From PHP to Ruby on Rails
From PHP to Ruby on Rails

From PHP to Ruby on Rails: Transition from PHP to Ruby by leveraging your existing backend programming knowledge

eBook
€22.99
Paperback
€27.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Table of content icon View table of contents Preview book icon Preview Book

From PHP to Ruby on Rails

Understanding the Ruby Mindset and Culture

Ruby has had quite a history since its inception by Yukihiro Matsumoto. The adoption of the language by the community has, of course, influenced the direction in which Ruby has been focused. But, at its core, Ruby has been very straightforward in the way you can and the way you should write programs/scripts with it. Every language has its own peculiarities, which the community takes to define what a good practice is and what is considered “bad” code. While this may be entirely subjective, this subjectiveness paves the way for what the author’s original intention for creating the language was into what the community wants the language to become.

Ruby was created with the idea of being extremely easy to read, flexible, and object-oriented. The same can be said about the technologies that came to pass because of Ruby. I’m talking about frameworks created in Ruby, such as Ruby on Rails (https://rubyonrails.org) and Sinatra (http://sinatrarb.com/). But I’m also talking about other tools that were created with that same mindset, such as Chef (https://www.chef.io/). All of these tools have common traits but the trait that stands out the most is readability. Once you’re in the Ruby “realm,” you’re able to read and understand code made for vanilla Ruby, a Ruby on Rails application API, or even a Chef recipe to manage and configure infrastructure. Ruby does not automatically make your code more understandable or readable, but it goes a long way to give you the tools to make your code easier to read. Making your code understandable is key to focusing more on the business (or hobby) at hand and focusing less on trying to understand what some code is doing.

But before we get there, we will need to make the switch to the Ruby mindset. In this chapter, we will start our journey into this mindset by covering the following topics:

  • Creating readable Ruby code
  • Object-oriented Ruby
  • Writing Ruby-esque code

You made up your mind to learn a new programming language. Congratulations! I, for one, would like to applaud this decision and hope it took you less time than it took me to be seriously curious about another programming language. I was a bit stubborn and reluctant at first, seeing every single downside of Ruby. My favorite phrase was, “I can do that in PHP easier.” But then, one day, it simply clicked and I never went back. Ruby has been my go-to language for a long time now. And I won´t try to oversell this to you. I refuse to say that Ruby is the best programming language there is because that would be answering a loaded question. There is no programming language that is universally better than the rest. What I can do is try to show you why I love Ruby.

Technical requirements

To follow along with this book, you will need:

  • Git client
  • rbenv (Ruby version manager to enable multiple versions of Ruby)
  • Ruby (versions 2.6.10 and 3.0 or above)
  • Any IDE of your choice installed to edit code (Sublime, Visual Studio Code, vim, Emacs, Rubymine, etc.)

All code examples have been written to work with Ruby versions 2.6.10 and 3.0 (or above). Some of the examples will need previous versions of Ruby (i.e. 2.6.10) to work with previous versions of Ruby on Rails (e.g. Ruby on Rails 5), but to guarantee that they work the same way as in this chapter, you should try to install the latest version of Ruby. You may get the installer for different operating systems here: https://www.ruby-lang.org/en/downloads/.

Additionally, to be able to use different versions of Ruby, I would also suggest you install rbenv from this GitHub repository: https://github.com/rbenv/rbenv.

The code presented in this book is available at https://github.com/PacktPublishing/From-PHP-to-Ruby-on-Rails.

Ruby is meant to be read as sentences

Having said all that about Ruby, let’s get our hands dirty and start with the most basic of concepts. You already know about PHP variables. Variables hold information that can be used and referenced in our program. Also, PHP is a dynamically typed language, which means that the PHP “engine,” which interprets our PHP code, will automatically infer the type of content within that variable. That’s to say the following two things:

  • We don’t have to define what type of content our variable has
  • A variable can change types without failing

Coming from PHP, you won’t have to break your head to learn a new way of using or defining variables with Ruby, as Ruby behaves exactly the same way. However, beware that in other languages that are strongly typed, such as Java, a variable has to be defined with the type that it will contain and it can’t change types over time.

So let’s play around with some variables in PHP:

<?php
$name = "bernard";
$age = 40;
$height_in_cms = 177.5;
$chocolate_allergy = true;
$travel_bucket_list = ["Turkey", "Japan", "Canada"];

Ruby is not much different in this scenario:

name = "bernard";
age = 40;
height_in_cms = 177.5;
chocolate_allergy = true;
travel_bucket_list = ["Turkey", "Japan", "Canada"];

For those experienced PHP developers reading this whose eyes might be bleeding from my lack of using PHP Standard Recommendation (PSR) standards on the PHP block, I apologize, but I wanted to give you a glimpse of how the code could be written in a similar manner rather than focusing on PHP’s best practices. Notice that we just wrote the variable names without the $ symbol. Another difference between PHP and Ruby is that we do not use any tag to denote PHP code, whereas, in PHP, we use the opening PHP tags (<?php). So, the main differences (so far) between our snippets are the way we call PHP code with the PHP tags and the way we refer to variables. While this is a functioning Ruby code, I intentionally wrote the Ruby block very PHP-esque to also give you all a glimpse of Ruby’s flexibility. Ruby is extremely flexible to the point of being able to bend Ruby’s own behavior. An example of this flexibility is that while we can add a semicolon (;) at the end of each line, it is a Ruby best practice to leave them out. Should this topic of Ruby’s flexibility interest you, you may want to check metaprogramming in Ruby. This Ruby guide is a great starting point:

https://www.rubyguides.com/2016/04/metaprogramming-in-the-wild/

But let’s not get ahead of ourselves, as this topic is really a complex one – at least for a beginner Ruby programmer.

Given the preceding code in PHP, let´s now determine whether the name is empty. In PHP, you would use the empty internal function. We surround it with another internal function called var_dump to show the contents of the empty function result:

$name = "Bernard";
var_dump( empty($name) );

This will output the following:

bool(false)

According to the documentation of the empty function, this is false because the name is not an empty string. Now, let’s try that in Ruby:

name = "bernard";
puts name.empty?;

There are a couple of things that we have to notice here. The first thing that comes to mind is that this is read almost as a sentence. This is one of the key points to how the Ruby community has come together and used Ruby to make code that is read by humans. For the most part, you should avoid writing comments on your code unless it’s for copyright and/or it does require an explanation. Ruby goes as far as having a strange way to write multiline comments. If I were to write a multiline comment on my code, I would have to look the syntax up because I’ve never used that notation. That’s not to say that you can’t or that you shouldn’t. It’s there for a reason. It simply means that the Ruby community seldom uses that notation. To write a comment in Ruby, you would simply add the hashtag symbol (#) as the first character on a line:

# This is a comment

As you know from comments within a snippet of code, this line will be ignored by Ruby. Keep in mind that a programming language, just like a spoken language, evolves due to its use. The best of tools may be lost just because no one uses them. Part of learning a language also involves learning the usage of the tools and best practices. This includes knowing what the Ruby community has decided not to exploit and what to use. So, while the community rarely uses multiline comments, all Ruby developers will take advantage of one of its most powerful tools: objects.

Everything is an object

The second thing that came to my mind while reading the previous code is that we are calling a method on a string. Now, let’s step back a bit, and this is where we start looking at code through our newbie set of Ruby eyes. Our variable name contains a string. Does this mean that our name is an object? Well, the short answer is Yes. Almost everything in Ruby is an object. I know this might seem as if we’re skipping a few chapters, but bear with me. We will see Ruby’s object-oriented syntax in Chapter 5. For now, let’s take this a step further within our code by getting what type of object our variable has with the following line:

puts name.class();

This will return the type of class of our object (in this specific case, String). We are able to do the same with the rest of our variables and we would get similar values (Integer, Float, TrueClass, or Array). And to take this even further to prove my point that almost everything in Ruby is an object, let’s read the following example:

puts "benjamin".class();

This will also return a String type. So, bear that in mind when you’re writing Ruby code. Now, let’s go back to the initial example with the empty function:

name = "bernard";
puts name.empty?();

The third thing we also notice is that we are actually asking a question. This baffled me the first time I saw it. How do you know when to ask? Is Ruby so intuitive that you can actually ask questions? What type of sorcery is this? Unfortunately, the truth is far less ominous than the code itself. In Ruby, we can name a function or a method with the question mark symbol as part of the name, solely to improve readability. It does not have any special execution or meaning to the Ruby interpreter. We are just able to name a method/function like that. Having said that, by convention, Ruby developers use the question mark to hint that we will return a Boolean value. In this case, it merely answers the question about the emptiness of the variable name. Simply put, if the name is empty, the question will return a true value, and vice versa. This naming technique is part of the Ruby philosophy to make our whole code readable. Additionally, this type of code style is permeated throughout many of Ruby’s internal classes. Some methods that are attached to number objects and array objects are an example of this. Here are a few examples:

  • .odd?
  • .even?
  • .include?

All these examples were named like that for the sole purpose of readability and nothing more. Some of them are even shared between different classes but have their own implementation for each type. While we are currently looking at the question mark symbol, let’s take a peek at a similar symbol: the exclamation point (!). Also known as a bang, it has a slightly different connotation within Ruby developers. Let’s look at it with an example.

Let’s show the name in uppercase letters. In PHP, we would write the following:

$name = "bernard";
echo strtoupper($name);

In Ruby, the same can be accomplished with the following code:

name = "bernard";
puts(name.upcase());

In both cases, this will return the name in uppercase (BERNARD). However, if we make any additional references to the name variable, the variable will remain unchanged:

name = "bernard";
puts(name.upcase());
puts(name);

This would return the following:

BERNARD
bernard

But what happens if we add the bang symbol (!)?

name = "bernard";
puts(name.upcase!());
puts(name);

This will return the name in uppercase twice:

BERNARD
BERNARD

The bang symbol in fact modifies the variable contents permanently. Functions that are named with the bang symbol are referred to as destructive methods because they modify or mutate the original object rather than just return the modified value. Examples of this are these methods from the String and Array classes:

  • .downcase!
  • .reverse!
  • .strip!
  • .flatten!

We can infer what they do just from reading them, but we now know what the bang symbol means in this context. Be careful when using these, but also don’t be shy of using them when the use case requires it. Now, when you read Ruby code, you will be aware of the question mark (?) and the bang (!) symbol.

Transitioning to Ruby

So far, we’ve seen examples in which our code looks very similar to PHP. As I mentioned before, I purposely did this to showcase the flexibility of Ruby. This makes the change to Ruby easier than other languages in which the syntax is a lot different than Ruby. However, this is only the beginning of our journey to becoming a Ruby developer. If we want to be able to read and write Ruby code and snippets like seasoned Ruby developers, we will need to see how the community has come to make Ruby code. In short, while we can write our code similar to other languages, we should avoid this practice and, in the process, learn about what Ruby has to offer to make our code more and more readable.

The first step we are going to take toward this goal is to remove unnecessary syntax within our code. To do this, we also must understand the utility of what we are removing.

Let’s take for an example our original code:

name = "bernard";
age = 40;
height_in_cms = 177.5;
chocolate_allergy = true;
travel_bucket_list = ["Turkey", "Japan", "Canada"];

In Ruby, the semicolon can be useful to separate multiline code into a single line dividing each line with a semicolon. If we took the name and the example to turn it into uppercase, we would have the following:

name = "bernard"; name.upcase!(); puts(name);

And this works perfectly fine. But remember, we are trying to make our code more readable. This is not more readable. It’s the opposite. And, if we are not going to write our whole code in a single line, then let’s take the original snippet (in multiple lines), and remove every single semicolon. This is starting to look more like Ruby:

name = "bernard"
age = 40
height_in_cms = 177.5
chocolate_allergy = true
travel_bucket_list = ["Turkey", "Japan", "Canada"]

This certainly seems to improve readability slightly by removing unused characters, but we are not finished. Let’s put this into practice with another example. Let’s write an example that will print out the string This person is allergic to chocolate if the value of the $chocolate_allergy variable is set to true. Because of our background in PHP, we might be compelled to write something similar to PHP. In PHP, we would write the following:

$chocolate_allergy = true;
if($chocolate_ allergy)
{
  echo "This person is allergic to chocolate";
}

With this in mind, we would write the following in Ruby:

chocolate_allergy = true
if(chocolate_allergy)
  puts("This person is allergic to chocolate")
end

This works fine, but it still looks a lot like PHP. An intermediate Ruby developer would most likely write something like this:

chocolate_allergy = true
puts "This person is allergic to chocolate"
  if chocolate_allergy

This is getting more and more readable by the second. But it also brings a couple of new practices to the table. For starters, the puts sentence is not surrounded by parenthesis. This is because, in Ruby, the use of parenthesis is optional for functions and methods. This is extremely useful as it’s starting to read like plain English. It works with functions with multiple arguments, too. As an example, an implemented function could very well look like this:

add_locations "location 1", "location 2"

Of course, this becomes cumbersome if we need to call nested functions. Let’s take this example with two functions:

def concatenate( text1, text2 )
  puts text1 + " " + text2
end
def to_upper( text )
  return text.upcase()
end

The concatenate function takes two strings and prints out both strings joined with a space between them. The second function just turns the input string into an uppercase string and returns the value. And this is where it could become problematic if we failed to use the parenthesis. If we wanted to concatenate the two strings and turn each string into an uppercase string, we could try the following:

concatenate to_upper "something", to_upper "else"

But we would fail miserably because the Ruby interpreter doesn’t know that "something" is the argument for the to_upper function. We can easily fix this with parenthesis:

concatenate to_upper("something"), to_upper("else")

Be careful with this knowledge as, like everything else, if overdone, it can be detrimental to our code’s readability. There are two additional points that we need to consider while deciding whether to use parenthesis. The first is that these rules also apply to the definition of the function. So, the concatenate function can be defined like this:

def concatenate text1, text2
  puts text1 + " " + text2
end

The second point is that the rule also applies to functions with no arguments – that is, we may remove the parenthesis from them, too. Let’s take the following as an example:

return text.upcase()

This will now become the following:

return text.upcase

More importantly, the use of methods that use the question mark and destructive methods (!) now make perfect sense for readability.

Let’s look at the following:

name.empty?()

This becomes as follows:

name.empty?

As another example, let’s take the following:

name.upcase!()

This now becomes as follows:

name.upcase!

The last point we will look at now is related to how Ruby behaves with the return of values. While a method can explicitly return a value with the return keyword, Ruby doesn’t need this keyword. Within functions and methods, Ruby automatically returns the last value that is referenced. Let’s use the following example for this:

def to_upper text
  return text.upcase
end

That example would turn into this:

def to_upper text
  text.upcase
end

You will see a lot of Ruby code like this. It can be intimidating and confusing at first, but once you understand what Ruby is doing, it simply starts to make more sense.

As you have probably realized by now, Ruby’s creator put a lot of emphasis on these tools to make it easier to write readable code. The community adopted this ideology and put it into practice. We not only see code using these conventions and rules to increment readability but we also see Ruby programmers adopt other conventions that, while they are not part of the Ruby rules per se, make perfect sense when used in context. I’m referring to variable and method naming. Because Ruby developers will try to make their code read like plain English, they will spend a lot of time thinking about how to name methods and variables to make the code more readable. For this reason, snake-case is more often used in Ruby, as it helps with readability. With that in mind, let’s look at this example:

chocolate_allergy = true
puts "This person is allergic to chocolate"
  if chocolate_allergy

We can still improve its readability. And it wouldn’t just be a syntactic change; it would also involve variable names and even defining a method, just to improve readability. So, a seasoned Ruby developer might write the final snippet for this example as follows:

def say text
  text
end
is_allergic = true
say "This person is allergic to chocolate" if is_allergic

As you can see, Ruby developers will go very far to make the code as readable as plain English. Of course, this is not always feasible and sometimes it’s not practical as it at times requires putting a lot of effort into writing even something simple, but for the most part, as long as it’s readable, by following these guidelines, other developers will thank you, not just the Ruby ones.

Summary

In this chapter, we covered the syntactic differences and similarities between PHP and Ruby, Ruby’s tools for readability, and Ruby’s syntactic flexibility. We also learned about the question mark (?) and the exclamation or bang symbol (!). Making it this far means that you are indeed trying to reuse your previous programming skills but with a new language: Ruby. This is a great start because you can skip one of the most difficult parts of learning a new language from scratch: the logical part. And while we’ve only seen the surface of Ruby, more importantly, we got a clear glimpse of how Ruby developers think when they’re writing code. We learned that to a Ruby developer, readability comes first. We not only use syntax and language constructs to make this possible but we also use objects to increase the code’s legibleness. The more it reads like a sentence, the better. We looked at some simple examples of Ruby, and while you could follow along, it was not the purpose of the exercise. It was more to pique your interest.

To move along on this learning path, we now need the proper tools to start writing and running Ruby code. In the next chapter, we will look at the different ways to install Ruby and set up our local environment so that we can start learning real examples of Ruby, and eventually follow along in the process.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand the notable differences between Ruby and PHP development
  • Gain practical experience and proficiency in Ruby by contrasting PHP examples with their equivalent Ruby counterparts
  • Explore how Ruby integrates into the Ruby on Rails framework and make insightful comparisons with PHP frameworks
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

Are you a PHP developer looking to take your first steps into the world of Ruby development? From PHP to Ruby on Rails will help you leverage your existing knowledge to gain expertise in Ruby on Rails. With a focus on bridging the gap between PHP and Ruby, this guide will help you develop the Ruby mindset, set up your local environment, grasp the syntax, master scripting, explore popular Ruby frameworks, and find out about libraries and gems. This book offers a unique take on Ruby from the perspective of a seasoned PHP developer who initially refused to learn other technologies, but never looked back after taking the leap. As such, it teaches with a language-agnostic approach that will help you feel at home in any programming language without learning everything from scratch. This approach will help you avoid common mistakes such as writing Ruby as if it were PHP and increase your understanding of the programming ecosystem as a whole. By the end of this book, you'll have gained a solid understanding of Ruby, its ecosystem, and how it compares to PHP, enabling you to build robust and scalable applications using Ruby on Rails.

Who is this book for?

This book is for PHP developers new to Ruby and Ruby on Rails. Whether you're a seasoned PHP developer or just starting out, this book will show you how you can transfer your existing PHP knowledge to Ruby and build web applications using the powerful Ruby on Rails framework.

What you will learn

  • Set up a robust development environment by configuring essential tools and dependencies
  • Understand the MVC model and learn effective techniques for working with Ruby libraries and frameworks
  • Integrate authentication functionality into your Rails application by leveraging gems
  • Find out how to process data from forms, URLs, and sessions within a Ruby on Rails application
  • Gain proficiency in using functions and gems for debugging and troubleshooting your Rails project
  • Create a simple Rails application, run it, and debug it in production mode
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 15, 2023
Length: 244 pages
Edition : 1st
Language : English
ISBN-13 : 9781804610091
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Estimated delivery fee Deliver to Malta

Premium delivery 7 - 10 business days

€32.95
(Includes tracking information)

Product Details

Publication date : Dec 15, 2023
Length: 244 pages
Edition : 1st
Language : English
ISBN-13 : 9781804610091
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Rust Web Programming
€37.99
From PHP to Ruby on Rails
€27.99
Mastering Linux Security and Hardening
€37.99
Total 103.97 Stars icon

Table of Contents

14 Chapters
Part 1:From PHP to Ruby Basics Chevron down icon Chevron up icon
Chapter 1: Understanding the Ruby Mindset and Culture Chevron down icon Chevron up icon
Chapter 2: Setting Up Our Local Environment Chevron down icon Chevron up icon
Chapter 3: Comparing Basic Ruby Syntax to PHP Chevron down icon Chevron up icon
Chapter 4: Ruby Scripting versus PHP Scripting Chevron down icon Chevron up icon
Chapter 5: Libraries and Class Syntax Chevron down icon Chevron up icon
Chapter 6: Debugging Ruby Chevron down icon Chevron up icon
Part 2:Ruby and the Web Chevron down icon Chevron up icon
Chapter 7: Understanding Convention over Configuration Chevron down icon Chevron up icon
Chapter 8: Models, DBs, and Active Record Chevron down icon Chevron up icon
Chapter 9: Bringing It All Together Chevron down icon Chevron up icon
Chapter 10: Considerations for Hosting Rails Applications versus PHP Applications Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.9
(7 Ratings)
5 star 85.7%
4 star 14.3%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Mr. B Dec 21, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book offers the readers an excellent understanding of how to transition from PHP to Ruby, regardless of experience. Transitioning from the parallel concepts of PHP to Ruby becomes simpler because of the great examples the author provides.The relativity of syntax, classes, and methods are explained from page to page allowing a PHP programmer to understand what’s analogous to Ruby and how it’s specifically used in real code examples.Ruby libraries (gems) are also covered as well as a thorough explanation of how to implement Ruby on the web. Overall, the author does a great job of comprehensively explaining how to shift from using PHP to using Ruby.
Amazon Verified review Amazon
ChordsBoy Dec 18, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm a web developer who has built over 5 projects from scratch, and have used PHP for the server-side code for all of them. I really love everything about how this book was written. It gave very clear, concise steps on how to leverage PHP concepts and experience to transition into using Ruby on Rails, with code readily available online and in the book. Very cool stuff, I would recommend :)
Amazon Verified review Amazon
null Dec 21, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
For those already familiar with programming languages like PHP or Python, this book is quite accessible. The author excels in offering easy-to-follow examples that illustrate the fundamental principles of using Ruby, as well as Ruby on Rails. Although PHP is mentioned in the title, the content is equally relevant for Python developers interested in learning about Ruby. The book is structured to quickly introduce Ruby, providing a basic understanding rather than deep dives. It's up to the reader to further explore and delve into more advanced topics in Ruby.
Amazon Verified review Amazon
HuguesTrezeguet Dec 16, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"Transition from PHP to Ruby" is an outstanding guide for PHP developers venturing into the Ruby realm. The book adeptly leverages existing backend programming knowledge, providing a seamless journey into Ruby.The authors establish a strong foundation by aligning Ruby concepts with PHP skills, making the transition smooth and intuitive. The hands-on approach, complete with practical examples, reinforces learning and ensures practical understanding.The book's well-structured progression covers key Ruby development aspects, including object-oriented programming, metaprogramming, and in-depth exploration of Ruby on Rails. The writing is clear and engaging, suitable for developers at all levels.In conclusion, this book exceeded my expectations, offering a perfect balance between theory and practice. Whether you're a PHP beginner or seasoned developer, "Transition from PHP to Ruby" is a must-read. It not only simplifies the transition but empowers you to fully utilize your existing backend programming knowledge in the exciting world of Ruby development. Highly recommended!
Amazon Verified review Amazon
wanderingslc Dec 27, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm a rails developer, and thought this was a great guide to moving into Rails. It does a great job explaining the similarities, and setting a developer up for success. If you're looking to transition, or learn more about Rails, this book is a great reference.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela