Learning Go for PHP Developers

Learn Go the Easy Way by Leveraging Your PHP Knowledge—A Practical Guide for PHP Developers Transitioning to GoLang.

Laravel Queues in Action

Go is a fantastic compiled language that is fast, memory efficient and has an amazing interface for dealing with concurrency. As a PHP developer who feels spoiled by the amazing developer experience PHP offers, you'll love Go.

This book is your fast track to learning Go as a PHP developer! We’ll start by breaking down core concepts and translating small PHP programs into Go—making the transition smooth and intuitive. Then, we’ll dive into Go’s most exciting feature: concurrency. Get ready for plenty of “Aha!” moments as you unlock its power. Finally, we’ll wrap up with a hands-on crash course in web development, databases, Redis, and APIs—equipping you with real-world Go skills so you can start writing programs in Go!

Book Contents

Getting Started

We’ll dive into Go’s philosophy and key features, uncovering why it’s a powerhouse for modern development. You’ll install Go, write your first program, and get hands-on with basics like variables and package management. By the end, you'll have a strong grasp of Go’s setup and workflow, ready to take your skills further!

Primitive and Composite Types

Mastering Go’s type system is crucial for writing efficient code. We’ll cover the basics, from integers to pointers, then dive into arrays, slices, maps, and structs—key building blocks for complex data. You’ll also learn how to define custom types and enums to keep your code clean and organized.

Control Structures

In this section, you’ll master conditionals for decision-making and loops for handling repetitive tasks.

Functions & Methods

In this section, you’ll learn to define functions, attach methods to types, and understand how passing by value vs. reference impacts your code. We’ll also cover variable scopes, the handy defer statement for cleanup, and dive into generics for writing reusable, type-safe code.

Object-Oriented Programming

Go takes a fresh approach to object-oriented programming, focusing on composition over classes. In this section, you’ll master struct embedding for code reuse, interfaces to define behavior, and constructors/factories to create objects. Plus, you’ll learn how to achieve encapsulation, keeping your code clean, modular, and maintainable.

Concurrency

Go’s concurrency model is a game-changer, and this section dives right into it. You’ll start with the basics of concurrency, then master goroutines—lightweight threads that make concurrent programming a breeze. Learn how to manage shared memory, use channels for communication, and understand the key difference between communication and memory sharing. Plus, you'll explore contexts to manage the lifecycle of your concurrent operations like a pro!

Errors and Panics

You’ll learn to work with Go’s built-in error type, create custom error types for clearer reporting, and handle unexpected situations using panics and recover, ensuring your programs stay resilient and robust.

Interacting with the World

In this hands-on section, you’ll learn how to interact with external systems and files in Go. From handling file I/O with readers and writers to embedding files into your app. We’ll also dive into working with JSON and YAML for structured data, managing Linux signals, and setting up effective logging to track your app’s behavior.

Web Applications in Go

Go makes web development a breeze. In this section, you’ll learn how to build web servers, route requests, and serve static files. We’ll cover handling cookies, using web templates for dynamic content, and creating powerful, scalable web apps.

Databases & APIs

The final section is all about data storage and integrations. You’ll dive into connection pooling, working with SQL databases, and leveraging Redis for fast, in-memory storage. Plus, you’ll master interacting with APIs, empowering you to seamlessly integrate external services into your applications.

Why Learn Go

PHP is great for building web apps, but a compiled language like Go gives you more control over performance and resource management. While PHP hides complexity behind abstractions, Go lets you fine-tune efficiency without sacrificing ease of use.

Also, with Go’s compiled nature, deployment is effortless—just upload a single binary, and you’re good to go. Plus, learning a compiled language deepens your understanding of programming beyond PHP’s abstractions, making you a stronger software engineer.

About the Author

Hey, I'm Mohamed Said, a software engineer living in Dubai, UAE.

I've spent over a decade building high-traffic web apps and PaaS with PHP. In the last three years, I’ve taken things to the next level by adding Go to my toolkit—extracting performance-critical parts into sleek, high-efficiency Go services.

You can find me on Twitter/X as @themsaid, and you can see my open source work on GitHub.

Grab Your Copy

Purchasing for a team?

With a team license, you can buy a single copy that you can share with all your team members.

Up to 5 team members for $160 → Up to 10 team members for $290 → Up to 15 team members for $400 → For Larger teams for $490 →

What you'll get

The book in pdf, epub, and html formats. Lifetime access to the book updates.

  • Pages 240
  • Last updated: Jan 30, 2024
  • Go version: 1.23
Grab an individual copy $39

Frequently Asked Questions

What happens after I buy?

After you purchase through Paddle (the merchant of record). You'll receive an email with the invoice followed by another with the book in PDF, EPUB and HTML formats attached. If you wish to download the book again later, you may do that from the purchases area by providing the order/transaction ID and the email address you used to make the purchase.

What personal information do you collect?

No personal information is collected when using this website, unless you choose to make a purchase. In that case, the personal data you provide during checkout is securely processed through Paddle for payment handling. Additionally, your email address is stored to ensure I can effectively support you if any issues arise.

Do you offer a refund?

Yes! Simply email [email protected] (or DM) within 15 days from the purchase and I will issue a refund. No questions asked.

Do you offer discounts?

If you are a student, unemployed or just can't afford it, email me at [email protected] (or DM).