I've been coding for over a decade & my very first website was built with HTML, CSS, & PHP all in a single index.php file (good old times). I decided to make my own channel and start producing content on things that I know & have learned over the years as well as the things that I will learn along the way. Currently, my main stack consists of PHP, Laravel, GraphQL, React JS (Next.js) & Tailwind CSS. (Though, I am planning on exploring other tech)
Happy coding!
X/Twitter - x.com/giodev8 LinkedIn - www.linkedin.com/in/giodev8 Discord - DM me on X for the invite Patreon - www.patreon.com/programwithgio
Gio , I have problem when I follow everything work until i reach at 7:50 created the View class but when i refresh the browser i get : Fatal error: Uncaught Error: Class "App\Controllers\View" not found in /var/www/app/Controllers/HomeController.php:10 Stack trace: #0 [internal function]: App\Controllers\HomeController->index() #1 /var/www/app/Router.php(55): call_user_func_array(Array, Array) #2 /var/www/public/index.php(25): App\Router->resolve('/', 'get') #3 {main} thrown in /var/www/app/Controllers/HomeController.php on line 10 i didn't get the error, I made the class in the app directory , everything was working until now and i don't know what is wrong?
Sorry to bother you, but if you see this message and you find some spare time, please write a few words about the following: When we customize "ResetPassword::createUrlUsing()" in a way that link in notification email points to "frontend domain" instead of "backend", is it posible to check URL validity (expiration time)?
I have a question that is indeed a bit to understand the key value of frameworks and dependency packages. In these I more often find self() instead of the static() that you mention and I understand the difference but guess it might be the same in this case to use the one or the other. In many above constallations the result is: class A { public function adapter() { $instance = B::create(); } class B { public static function create() { return C::create(new self()); } class C { public function __construct($value) { $this->value = $value; } public static function create($value):self { return new self($value); } For me this is confusing and not readable. I guess the result is that I have $instance that is an object of class C and has access to the object of class B through $instance-value. Am I right? Why that complicated?? For me object orientation is to get more clearity to the code but in a framework and similar it for me only results in mad code chaos. I understand what the method of A shall do but it runs through two other classes that have nothing to do with it to achieve it. I simply don't understand why I should include such a mess into my code. Could you please tell me: If I really understand what the framework/package does, do you think it is still better to rely on the framework/package or is it better to use my own code that simply returns the exactly same result but more readable and/or faster with less extra loops? I more and more come to the point that it only makes sense to use a framework if you ignore what it does in the background and just rely on the results it offers. For me I would always want to either to understand all the third party code or varify every result coming from that code. I guess that is no effective coding....
Great videos. One point - the volume varies a lot from video to video. You should put a compressor on the audio track in your video editing software - that'll level out the audio levels and make them more consistent across all your vids.
I would like to use docker. But on windows it works too slow. I've got problems with installation already. It downloads very slow. So thank you for advicing laragon
Hi Gio, do I understand correctly that instead of enum->value you could provide an enum and the ternary will accept as well cause it is an instance of $backedEnumClass?
I hope you’re doing well! I really enjoy your content, especially the PHP & Laravel series. I believe a series on WordPress core development, focusing on plugins and theme development, would be incredibly valuable. Your expertise would provide great insights for many of us looking to enhance our skills.
Gio, could you pls say what I'm doing wrong with testing setting class in container? #[Test] public function testItSet() { $users = new class () { public function index(): array { return [1, 2, 3]; } }; $this->container->set('test', $users::class); $this->assertSame($users::class, $this->container->get('test')); } 1) tests\Unit\ContainerTest::testItSet Failed asserting that class@anonymous /var/www/tests/Unit/ContainerTest.php:40$d9 Object #296 () is identical to Binary String: 0x636c61737340616e6f6e796d6f7573002f7661722f7777772f74657374732f556e69742f436f6e7461696e6572546573742e7068703a3430246439. /var/www/tests/Unit/ContainerTest.php:47
I was initially (some many years ago) put off by Symfony and Doctrine because I dislike annotiations, I just can't stand looking at them... Native PHP attributes change everything. It looks beautiful. As my projects got complex, so I was looking for a more DDD approach with proper SoC, but was fighting with Laravel to get it right, it finally clicked why Data Mapper is preferred over Active Record. And here I am. My good sir you have a knack for explaining things; Do you think you can make or recommend a video or a resource that breaks down proper DDD planning in terms of aggregates, entities, value objects, preferably for someone from Active Record background switching over to Data Mapping?
I love when you say "but let's keep it simple" and there are over 7 php files and hundreds of rows of code 😇😆😆 I suppose that will be clearer for me once I have fully check the Laravel lessons. I like how you show a few different ways for something, even though I'm a little bit confused sometimes. Thanks again and we keep going!
Thank you for your time and efforts to make these amazing videos ! Have you got plans to make videos about a bit more advanced things like rabbitmq, kafka, grpc, static analizers or maybe "learn symfony the right way"?)
Gio, I'm a bit confused about concepts. Am I right that general name for all fake classes are Mock objects that in turn can have fixed output ("to stub") or do output via expectations ("to mock")?
For some reason, I get stuck on 8:33 part of the video, when the router is optimized to work with arrays. Any idea what could be fixed? It just throws the same routes error that is created earlier in this lesson, no idea why the URIs are not cathed properly.
I have to be honest. I skipped this video in first instance as I do not use MySQL and as I am already used to SQL in several variants and dialects for quite a long time. Indeed this is the first of your tutorials where I did not learn anything new. BUT It was once again a pleasure to just watch, see and hear you putting together all these really hard topics, explain all important things and make me wonder why I needed so much time to get this knowledge in the past. Great work! Maybe one small tweak to mention: You explain Safe Update Mode and I appreciate this as not only many beginners but even big companies do not use it. Why not showing your audience where and how to activate it? Would you give me your opinion on one thing: I personally prefer SQLServer/TSQL/SSMS and like Oracle as well (I have no real reason but it imo comes more handy when you want the DB-Server to do the things on its own instead of your app/web server). It's really seldom that I see people talking or working with TSQL in combination to PHP. Are there really actual reasons maybe limits with this combination? Or do you think it might just be because of older versions that did not match/had conflicts?
Switching back and forth inside your videos while understanding PHP more and more I remembered your mention at 4:58 "The use of static methods and properties is generally considered a bad practice" Now Laravel has these Facades - that as far as I understand - enable us to simply have a static counterpart of every of our classes/objects. Would be great if you could explain why this is a really good usecase. I guess there might be a new video on Facades in your laravel course? btw.: I have not mentioned by now that also this video is great 🙂
I have a video on Facades that will be released a bit later that explains this exact thing. Facades are not same as static methods, in fact, facades dont define static methods. It just proxies the call to the actual object that defines the method (which is non static). It is just a PHP's call static magic method implementation
@@ProgramWithGio @8:00 you mention that we will talk about singleton pattern in more detail later in this course. Similar to what I said about Facades I would like to understand a bit more about singletons as I see that these are really used a lot and I would like to see if I should or should not refactor all these to DI in my own project instead of just taking what others built out of masses of singletons. One example for this is the dotenv you include in PDO part 2 later on. As far as I can see by including this to my project I include 13 singleton classes plus many singletons from the dependecies of this 'module'. Once again I am not confident that it is overall bad practice in such a case but I would like to be able to understand it similar to the Facades matter. Can you tell me if there is a later video in this course that I possibly have missed that covers singletons a bit deeper?
Wow, the least part with the cached routes blew my mind. Where I was clearly understanding how composer caches the autoloading in a simple array with key/value pairs, I wonder how such a deep array tree can really speed up the routing. Can you explain or even show how laravel reads from this "array monster" efficiently? I must have missed that in your PHP series but I would possibly end up in a "if/else monster" to bring the routes to action I guess... There must be a really quick soloution, right?
If you open the cached routes file you will see its not just a giant array, it sets compiled routes on the router instance. Then uses that compiled routes to find the appropriate route.
Hey Gio, once again a terrific example of your teaching strength! massive content brought to comprehensive words! Thank you soo much! This will for sure be a video that I will review from time to time whenever I will retry to understand what laravel routes work like.
Gio can you maybe explain to me why, when I pass an array through the params in the way you explain it, inside the view empty($this->array) - same for other options you show - returns true even if empty($this->array[0]) returns false? The array is not set but can be accessed without problems and the array's content is set. I guess it is something related to ob_get_clean() or to the __get() method but I can't figure out, where it really switches. Inside the View class empty($params['array']) returns false.
@@ProgramWithGio thanks, your tutorials are really good btw, im finishing a tutorial about apache and going tô come back to your PHP tutorial. Always something New tô learn
hey Gio, I watched this lesson maybe 5-6 times now. Not because it is hard to understand. I already have used the MVC pattern and heard about it in numerous variants. I really apreciate that you not only teach how to implement your picture of it but that you give us your ideas about it. There are weird variants out there (my first contact was someone teaching to creat Controllers as child class of the Model and Views as child class of the Controller for me that lacked the logic of general object oriented programming. You enable me to think further and in a way create my own "style" / to decide what pattern and what logic fits best to my thinking. Thank you sooo much! In regards to validation I would like to hear your idea about my thoughts: I think as you mentioned that validation that ensures that there is no wrong/useless content or that shall result in direct response to the user for correction, should be an extra layer on the controller side. But there are similar "validations" that I call different: - normalization - If incoming feed has to be formatted / transferred into a form that fits to the internal usage inside the app. This shall in my opinion ba a layer of the model so that the controller sends the raw data to the model side, the normalizer returns the correct form and the controller might go on to work with the data or the normalizer goes on on model side to store the data in correct form. Example: validation that internally transfers all times to one timezone to enable comparison, formatting all floats to integer due to more reliable calculation... - escalation - this term is not perfect, maybe you find a better. For me this is the validation that is close to the error handling. In short every validation that indicates that the app might be used incorrectly, internal procedures might be harmed or critical situations must be avoided - should be an extra layer of the error handling and as part of this, part of the model / business logic. Reason for this in my opinion is that my code shall not only ensure the correct form/disable the unwanted features but might got farward and identify the source of the bad data, set up a monitoring to enable risk analysis. Example: HTML special characters handling, request timeouts, file validation of correct type/content relation...
You can have as many layers as needed as long as you dont overcomplicate/overengineer stuff. Formatting can happen in its own layer, can happen in a service class or can happen in controller as well & model can receive a DTO or already normalized/formatted data. Many different approaches. As long as you are not bloating either side, you should be ok. I personally would take the extra layer approach to avoid bloating controllers
I have a question that this experession $x = floor((0.1+0.7)*10); evaluates to 7 but when I remove floor function then it evaluates to 8. If 0.1 and 0.7 does not have accurate binary representation then it should calculate to 7 without floor also but it evaluates to correct value 8. Why it is happening? Can you please clear me?
Floor rounds it down, the actual number is very close to 8 so if you dont apply floor then PHP just rounds it up to 8 cause the number it evaluates to is something like 7.999... I mentioned that at 2:20
Hello Gio, in the examples of using the call() method why didn't you use the splat operator and instead used call_user_func_array(), is there any advanced reason for that, like a better performance from call_user_func_array()?
@@ProgramWithGio Thank you for your response, its not only the course that is great but also you as a person for not being arrogant and helping others learn what is best to learn and updating the course two years later❤
I started watching and learning from your videos in this playlist about 1-1.5 months ago. Some topics in some videos were very difficult for me to understand and remember. However, this quick overview of Composition vs Inheritance was one of the videos that I found really helpful and easy to understand. Thank you!!
I just wanted to say, that I found this course in 2022, and its really brilliant in world of Php courses. After completing this course I easily found a job, where I developed my skills more and more. I want to thank the author of this course. You did a great job, now I’m getting close to 2 years as Php developer. Wish you all the best, bro
Hee Gio, silly question. Isn't it counter making a tight coupling to the entities with the service architecture? (If later on you want to distribute the service to grpc or api) (Although it works beautifully and fits inversion of control)
How do you manage to return invoice status enum as string because I dont see any formatting section in your code because In laravel eloquent I see you use map method with a closure getArrayResult and select you put i alias which return hydrated entity
@@ProgramWithGio 6:03 what I ask how to format in order to get status as a string because I get error saying twig can't convert InvoiceStatus to string
->value on enum object. That's why I asked you if you could refer to specific part in the video I could provide better direction, 6:03 you referred doesn't show invoice status so I got confused.