Skip to content

Instantly share code, notes, and snippets.

@hxtree
Last active May 17, 2022 16:13
Show Gist options
  • Select an option

  • Save hxtree/2f4584d86dcf1379f4e33484ad00b9f0 to your computer and use it in GitHub Desktop.

Select an option

Save hxtree/2f4584d86dcf1379f4e33484ad00b9f0 to your computer and use it in GitHub Desktop.
PHP Coding Resources

Overview Best Management Practices

https://phptherightway.com

PHP standards

Security BMP

https://www.zend.com/blog/tips-php-security

Automated testing

https://phpunit.de/

Package Manager

https://getcomposer.org/

Design Patterns

https://designpatternsphp.readthedocs.io/

Refactoring Guru

https://refactoring.guru/

How to Document Your Code

https://docs.phpdoc.org/index.html

S.O.L.I.D. Principles of Object Oriented Design

By Robert C. Martin in 1995, named by Michael Feathers

  • S - Single-responsibilty principle ** A class should be responsible for one thing. ** That does not mean single task. ** Small class with specific names and responsibilty. ** Find one reason to change and take everything else out of the class.
  • O - Open-close principle
  • L - Liskov substitution principle
  • I - Interface segregation principle
  • D - Dependy Inversion Principle

https://www.youtube.com/watch?v=GtZtQ2VFweA https://www.youtube.com/watch?v=Q61TtJlWvfE

Don't Repeat Yourself

The Boyscout Principle

  • Don't try to rebuild a whole project when editing it. Instead, leave it cleaner than you found it.

Separation of concern

  • Code should do what it is supposed to and nothing else.

Interfaces

  • If you only have one type then an interace is not needed. IT helps to extend without need to modify.

YAGNI

  • You ain't going to need it.

When if returns don't use else

"Your code sucks, let's fix it - By Rafael Dohms"

Why to clear between method bracket

ITT 2016 - Kevlin Henney - Seven Ineffective Coding Habits of Many Programmers

Dependancy injection

https://en.wikipedia.org/wiki/Dependency_injection https://www.youtube.com/watch?v=RlfLCWKxHJ0 law of delimiter, DI, testing, etc. Inject dependencies into properties https://php-di.org/doc/autowiring.html Autowiring

Initializing objects inside constructor is a code smell

https://stackoverflow.com/questions/15901861/why-not-instantiate-a-new-object-inside-object-constructor

Floating point numbers

https://floating-point-gui.de/languages/php/

Robustness Principal

"be conservative in what you send, be liberal in what you accept" https://en.wikipedia.org/wiki/Robustness_principle

Unix Philosophy

Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

https://en.wikipedia.org/wiki/Unix_philosophy

Null pointers

Tony Hoare https://www.youtube.com/watch?v=ybrQvs4x0Ps

Test Pyramid

https://martinfowler.com/articles/practical-test-pyramid.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment