[0:05] hello and welcome to the second section [0:07] of the learn php the right way course [0:09] in the first section of the course we [0:11] covered the core concepts of php like [0:13] data types casting control structures [0:15] functions and so on though most of the [0:17] things that we did in the first section [0:19] of the course we did it using the [0:20] procedural php [0:22] it is time to move on to object-oriented [0:24] php in procedural programming an [0:26] application or a program is divided into [0:29] a set of functions that operate on some [0:31] sort of data that are stored in [0:32] variables [0:33] so you basically have some sort of [0:35] global state or variables [0:36] and then bunch of functions that work [0:38] with those variables [0:40] you could also have functions called [0:41] other functions and so on in [0:43] object-oriented programming however [0:45] you're basically combining or bundling [0:47] related functions and variables into [0:49] something called a class [0:51] from which you create objects you could [0:53] access variables and call functions of [0:55] the object if they are publicly [0:56] available we refer [0:58] to the variables of the object or the [0:59] class as properties [1:01] and the functions as methods i mentioned [1:03] a class so what exactly is a class and [1:05] what's the difference between a class [1:07] and an object [1:08] in simple terms basically a class is a [1:10] blueprint and an object is something [1:12] that you create or build from that [1:14] blueprint you could have many objects of [1:16] the same class but each of those [1:18] objects can be different let's take a [1:19] house as an example the blueprint of the [1:22] house would be your class [1:23] and the house itself would be the object [1:26] you could have multiple houses based on [1:28] the same blueprint with slight [1:29] differences they can have different [1:31] paint colors they can have different [1:33] layouts and so on [1:34] in other words objects are simply [1:36] instances of the classes the main [1:38] advantage of object oriented programming [1:40] is the ability to structure your code in [1:42] a better way that is easier to maintain [1:45] test extend debug and so on though this [1:47] does not mean that procedural [1:49] programming is useless [1:50] there are some use cases for procedural [1:53] programming it might [1:54] be a good pick for a small project that [1:56] does not require many features or much [1:58] maintenance and you're the only one [2:00] working on it or maybe it's a simple [2:01] transcript [2:02] basically not everything has to be [2:04] object oriented but as your code grows [2:06] and your project requirements increase [2:08] you will find yourself in a trap where [2:10] modifying extending and maintaining that [2:12] code becomes difficult [2:14] especially when you're working in teams [2:16] this is where object-oriented [2:17] programming can help you but do note [2:19] that object-oriented programming does [2:21] not mean your code will automatically be [2:23] easier to maintain [2:24] essentially it is up to you as a [2:26] developer to ensure that you write your [2:29] code in a way that is maintainable [2:30] extendable readable and reusable [2:32] object-oriented programming just makes [2:34] it easier for you to [2:36] write such code also object-oriented [2:38] programming is on demand [2:39] meaning that you won't find many [2:41] companies looking for programmers with [2:43] experience in just procedural [2:44] programming most of them require [2:46] object-oriented programming skills thus [2:48] object-oriented programming mean [2:50] mvc no and this is the misconception [2:52] that i see a lot an object-oriented php [2:55] does not [2:56] automatically imply mvc object-oriented [2:58] programming is a programming paradigm [3:00] while mvc is an architectural pattern of [3:03] modal [3:04] view controller which uses the [3:06] object-oriented programming principles [3:08] and we'll talk about this more later in [3:09] the course but basically [3:11] object-oriented programming does not [3:13] imply mpc [3:14] object-oriented programming has four [3:16] main principles and these are [3:18] encapsulation abstraction inheritance [3:20] and polymorphism and we'll cover these [3:22] principles in detail in separate videos [3:24] so don't worry about them right now [3:26] let's talk a little bit about what you [3:28] can expect and learn from this section [3:30] of the course [3:30] in this section of the course we'll [3:32] cover how to create classes and objects [3:34] what are magic methods and go over the [3:36] use cases and examples [3:38] we'll cover code style and psr standards [3:40] namespaces autoloading and dependency [3:42] management we'll cover all four [3:44] principles of object-oriented [3:46] programming in more detail with actual [3:48] examples and of course we'll cover [3:50] things like [3:50] traits statics super global sessions [3:53] cookies connecting to databases and much [3:55] more and don't forget there is also a [3:57] third section of the course which will [3:58] cover much more advanced [4:00] topics so this is it for this video let [4:02] me know in the comments if you have any [4:03] questions or feedback [4:04] if you're looking forward to learning [4:06] more about php please give this video a [4:08] thumbs up which by the way helps a lot [4:10] with youtube's algorithm [4:11] share and subscribe and i'll see you on [4:13] the next video where we'll get php [4:14] installed using docker and start [4:16] exploring object-oriented php more