Ali_Hegazy Posted yesterday at 01:29 AM Share Posted yesterday at 01:29 AM Hello developers , I am learning PHP and I have an obstacle at OOP, when I read about it on any website like w3school I understand most of it but I don't know how to apply on it , and when I went to move towards in PHP I see that this thing need deep knowledge about OOP and I move in this cycle , NOTE: I already learned OOP with C++ in college so I just read about OOP in PHP and I don't see full course on youtube because I don't want to hear the same principle again , if what I am doing is wrong please tell me . Thank You. Quote Link to comment https://forums.phpfreaks.com/topic/329752-how-to-practice-on-oop/ Share on other sites More sharing options...
Solution gizmola Posted yesterday at 02:21 AM Solution Share Posted yesterday at 02:21 AM C++ OOP is more complicated, so you should not be having issues picking up PHP OOP. For example, PHP OOP doesn't have templates/ operator overloading or multiple inheritance. The best examples of how to apply OOP are those you find in some of the better known component libraries, and in particular those associated with Symfony and Laravel. For everyday use, you want to learn about the Design Patterns described in the Gang of Four book. You don't have to buy this book to learn about these OOP design patterns but many people do, and it's a common text book from my understanding. There are similar books specific to PHP, but I can't personally vouch for any of them. One of the most important OOP design patterns is the Dependency Injection pattern (sometimes called "Inversion of Control"). There are a number of well regarded frameworks that fundamentally are Dependency Injection frameworks. Spring (for Java) was one of the first I was aware of, and for PHP Symfony and Laravel are both DI frameworks, as are any number of other frameworks, given the advantages of the pattern. You want to read about Dependency Injection. There's an article here, that talks about DI and has some examples: https://php-di.org/doc/understanding-di.html Coming from C++, you should already have a good handle on inheritance, methods, constructors, variable scoping, static variables and methods, etc. You want to learn about PHP Interfaces and more recent PHP additions like traits. For free video material, there are any number of tutorials and free courses that cover PHP OOP. I have frequently recommended this channel, and many experienced PHP developers seem to agree with me, that he does a good job covering the syntax and providing examples. Quote Link to comment https://forums.phpfreaks.com/topic/329752-how-to-practice-on-oop/#findComment-1656384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.