What are the design patterns in PHP
PHP design patterns
- Home »
- For advanced »
- object oriented programing »
- PHP design patterns
Design Patterns, or in German Design pattern, are proven solution patterns for frequently recurring problems. They provide a reusable template for problem solving. As a programmer, you can fall back on these tried and tested design patterns in many ways and thus face the task of generating good program code. In this short tutorial we can only introduce you to the most important design patterns in PHP. If you want to learn more about the topic, I can recommend the book PHP Design Patterns.
Design patterns are here Not to be confused with web design. Design Pattern is about good code, not beautiful web design. All design patterns here relate to object-oriented programming and help you determine how and which classes you should create for your application.
The most important design patterns for PHP are listed and explained in more detail on the following sub-pages.
Get and Set methods
Access to class variables can be controlled using get and set methods. The Get method returns the value for each class variable and the Set method updates it. In this way, it is possible to centrally control how certain class variables can be accessed.
Model-View-Controller in PHP
The Model-View-Controller (MVC) design pattern is one of the most important in PHP. The application is divided into three layers. The model classes bundle all functions to access the database. The views represent your data in the browser. And the controller implements your application logic.
Using the template pattern, a template is generated for different variants of an algorithm. Individual sub-steps of the algorithm are defined as abstract methods. The child classes then implement the concrete implementations of the algorithm.
- How do I deal with confusing emotions
- How has science made us less human?
- What is CRWD
- Why is my Barclaycard rejected?
- Why does someone kill wrongly
- How do I audit a European company
- How does the queuing culture differ between countries?
- POA is required for trading intraday options
- Which corporate brand is OnePlus
- Overrated in college
- The universe could have been different
- When does IPL end
- How do I die in the fire
- Why do people seldom dress up anymore
- Can single-use medical devices be sterilized?
- What is the spelling of the instructions
- Why do people say the seven seas
- What's found in pens
- What are educational standards
- How does Uber work in Ghana
- Who invented the modern internal combustion engine
- All metals form metallic bonds
- Who pays for big concert tours
- How many named stars are there