r/PHPhelp • • Feb 17 '18

PHP Design Patterns Book

Hi everyone, can any of the advanced PHP programmers out there recommend a great PHP design patterns book? Something that is really widely applicable hopefully, as I want knowledge that will apply broadly. The reason I want one written in reference to PHP is because I'm a web developer and am better with PHP than anything else so it feels like a very relevant choice for learning more about design patterns in general.

I'd also want something pretty current. Published post-php7 is what I'm thinking.

Thanks very much for anything you come up with.

8 Upvotes

18 comments sorted by

4

u/mgkimsal Feb 18 '18

what have you read already?

  • maintaining legacy software by michael feathers is good. it's not specifically "design patterns", but it's a good walk through discussing code, what makes code easier to maintain, etc. "refactoring" from martin fowler is similar, but I think the feathers book is more practical

  • the "head first" series is generally good, and they have a design patterns book

You won't find much specifically on PHP and design patterns in book format. In true "open source" fashion, I'll throw back at you that you should be the one to write it. :)

1

u/[deleted] Feb 20 '18

Yeah I figured PHP would be a hard one to find specifically. Found several on Amazon, but I don't trust them without some redditors' reccomendations haha.

3

u/[deleted] Feb 18 '18 edited Feb 18 '18

Check out Robert Martin's (Uncle Bob) clean code series. The videos or the books.

But since you're looking for books, look at Clean Code. Most of the examples are in Java, but it shouldn't be a problem to translate to php. It's about patterns, not about the code itself.

1

u/[deleted] Feb 20 '18

Yeah I've heard a lot about Clean Code, and I want to get that too!

2

u/CyberJack77 Feb 19 '18

It's not a book (although you can download a PDF), but as a quick reference I keep a bookmark to: https://github.com/domnikl/DesignPatternsPHP (or the readthedocs pages on http://designpatternsphp.readthedocs.io/en/latest/README.html)

1

u/[deleted] Feb 20 '18

Thanks, added to my PHP bookmarks folder!

1

u/xammie12 Feb 17 '18 edited Feb 18 '18

I don't get it.

Why do so many people read books (Or at least want to) to learn programming? I've never touched a programming book and never needed it myself. They get old really really fast. The internet is full of free learning video's, articles, blogs and probably more.

EDIT: Why the downvotes? I'm just asking questions, this is a help subreddit right?

5

u/[deleted] Feb 17 '18

The simple answer for me is that I sometimes have spent my entire day doing work or learning things on my computer, and it would be nice to do something productive that doesn't involve staring at a monitor. Additionally, a very well received book sometimes has the bonus of being compiled by an extremely knowledgeable person who knows exactly what the most useful information is, and the best way in which to present it. The same could certainly be said of many online resources but a very well written book thought highly of by many people is guaranteed to be worthwhile knowledge.

I also just enjoy reading books. It is a nice format to me subjectively.

1

u/xammie12 Feb 18 '18

Yeah i can get behind your points :)

I personally find reading official documentation the best way to continue learning once you've already started programming and have the hang for it. But for starting with little to no experience I can understand the pros of a book.

Also, Even if a author is very knowledgeable of the thing he/she is writing about. It will get old, and I feel like with something like programming this can be fast. But ofcourse this is not only books. Video's, articles and blogs probably have the exact same.

I hope you find what you are looking for!

2

u/[deleted] Feb 18 '18

Thanks, and I agree with you mostly. Design patterns seem mostly persistent though, or at least become outdated at a much slower rate than other programming material. I also love reading official docs, its how I've learned most of what I know about Laravel. Thanks for the responses!

2

u/xammie12 Feb 18 '18

Our whole conversation I was having the whole of programming in my head not thinking about your question, whoops my bad.

2

u/liquid_at Feb 19 '18

If you happen to feel comfortable with a compromise, www.phptherightway.com/ has a link to the ebook-version of the site in pdf, epub and mobi format on Leanpub.

But content-wise, they are to the webdesigner what a dictionary is to an author... It's pretty much the goto guide for design patterns and best practice in php these days.

7

u/[deleted] Feb 18 '18

I've never met a senior developer that didn't read books.

2

u/xammie12 Feb 18 '18

Well, Here I am :)

6

u/AllenJB83 Feb 18 '18

While language specific books, particularly for younger languages, that are basically tutorials do get old fast due to language evolution, there are many books which don't because they're more about algorithms or methodologies which don't change so much over time (all that changes is specific details or the language you use).

Examples include:

  • The Clean Coder series (Clean Code, Clean Architecture, etc) by Robert C ("Uncle Bob") Martin

  • Patterns of Enterprise Application Architecture by Martin Fowler

  • Design Patterns by Gamma, et al (this and PoEAA are pretty much straight up reference books - "dictionaries" for design patterns)

  • Refactoring by Martin Fowler

  • Domain Driven Design by Eric Evans

  • Growing Object Oriented Software, Guided by Tests by Steve Freeman & Nat Pryce

Additionally there are cases with older languages that are no longer evolving at such a pace where books are still useful, particularly when you're learning a language more for the experience of a particular paradigm than producing useful software in that language.

3

u/___jamil___ Feb 18 '18

people learn in different ways.

2

u/Ghosty141 Apr 06 '18

You don't read the book to learn programming, you learn about software architecture, how to refactor (which is an amazing skill to have) or which patterns to use.

For smaller and especially newer code-bases/projects you won't need books that much compared to 500.000+ lines of code where half of it is over 10 years old. Refactoring old code that is often heavily dependant on other parts is something you will not be able to do just by learning-by-doing.

Just a question, do you work as a SE and if so, how much legacy code do you work with on a day-to-day basis?