Laravel Contracts and PHP Interfaces: Explained with Two Examples

  Рет қаралды 43,894

Laravel Daily

Laravel Daily

Күн бұрын

Пікірлер: 40
@thelostrider1
@thelostrider1 3 жыл бұрын
Nice video. When using Laravel people seem to forget that Laravel is PHP and end up don't learning OOP or "pure PHP" (mostly because it's kinda easy to use Laravel without much knowledge of PHP). That's something I don't like, even tho I'm learning Laravel I feel the need to learn more about pure PHP and OOP in general
@VadimBesedin
@VadimBesedin 3 жыл бұрын
So, as i understand, interface would be good for situation when i need to process payment. One interface and several payment provider classes will be implementing that interface. Also later i will be able to add just another payment provider class and it will work with present interface. Right? It's like USB, you can connect different devices to it, and they will work normally because they implement this USB interface.
@DennisZiolkowski
@DennisZiolkowski 3 жыл бұрын
Thats a good explanation!
@dclindner
@dclindner 3 жыл бұрын
Given PHP's limit of extending from only one class, you can't rely on on abstract class, necessarily, if you're providing code to be used by others (such as open source packages). it seems common to define an interface with the methods required, and include a trait that defines those methods. I found this confusing at first, but very helpful to add functionality while working around the one-class extends limit.
@vivekwah
@vivekwah 3 жыл бұрын
I always have trouble deciding to use either interface or abstract class. Can you please help with this confusion.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Ok adding the interface and abstract classes to the to-do list.
@igoreksazonov
@igoreksazonov 3 жыл бұрын
its up to your mind
@vivekwah
@vivekwah 3 жыл бұрын
@@igoreksazonov yes till now I have been using with that mindset only. But in some good repos I've noticed in some places abstract classes are used and some places interfaces. I only have difference with respect to inheritance. Using abstract class we restrict extend with that class whereas in case of interface there can be many interfaces implemented.
@kaczuszka-dt
@kaczuszka-dt 3 жыл бұрын
Abstract classes do offer some functionality, its not just structure, its the actual functionality with something in already. Interfaces offer only and only description of what the class should be capable of, we cannot give it any real properties or functionality, just a shared set of methods
@Laflamablanca969
@Laflamablanca969 3 жыл бұрын
The interface for the relationship is pointless. It’s just adding more complexity than is needed.
@flashandrew6772
@flashandrew6772 3 жыл бұрын
Thanks for the video! It also can be great to see some videos like “middle” level of difficulty. For example something about compare ORM and CQRS. Or maybe some explanation about concepts of DDD
@lucasj.pereira4912
@lucasj.pereira4912 3 жыл бұрын
Also websockets
@LaravelDaily
@LaravelDaily 3 жыл бұрын
For now, I'm focused on practical topics and not theoretical concept comparison. Maybe, when I run out of practical topics, I'll switch to the philosophy on this channel :)
@itone3438
@itone3438 2 жыл бұрын
thanks
@free2idol1
@free2idol1 Жыл бұрын
I noticed that the author used this function to name his file: $filename = uniqid().'_'.Str::random(30) . ".png"; => if you loop through 10 files and using above function to name your file, is there any chance that you would get duplicate file name?
@soniablanche5672
@soniablanche5672 3 жыл бұрын
interface is the opposite of trait, instead of being provided with methods you have to implement them yourself.
@patricksantino4131
@patricksantino4131 3 жыл бұрын
You don't say 😂
@eduardoromao
@eduardoromao Жыл бұрын
Can be named “API”. Its more natural above Interface and Contract. API provides a contract for another service. So contract and API is the same thing, but i’m below API term is already used in hardware and software like a standard, not needing new term like contract.
@Jagdish0724
@Jagdish0724 3 жыл бұрын
User hasMany(cities) City hasMany(Users), hasMany(Restaurants) Restaurants belongsTo(City) Orders belongsTo(Restaurants) now there are city wise admins. admins can see orders of their assigned cities only with global scopes to other cities records . How to create this relationships.
@ajithlal1688
@ajithlal1688 3 жыл бұрын
I was struggling to understand interface and this video gave me a better understanding. Thank you ❤️
@L-A-O-S
@L-A-O-S 3 жыл бұрын
There are still abstract classes awaiting you, which will only create more confusion. )
@pasizdobrekuce
@pasizdobrekuce Жыл бұрын
Dependency inversion FTW. 🙌
@linkernetir
@linkernetir Жыл бұрын
thank you for the best explanation about contracts in laravel.
@L-A-O-S
@L-A-O-S 3 жыл бұрын
Oh, OOP is already here) Cool, well then you should take into account that there are also abstract classes. It's just difficult to rebuild your logic in order to start using all this, although the advantages are immediately felt. And looks like interfaces should be named like gates or politicians? liked the topic of using oop in laravel
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Ok adding the interface and abstract classes to the to-do list.
@Bevallalom
@Bevallalom 3 жыл бұрын
Laravel is PHP OOP mostly..... Just saying.
@lma_cristian
@lma_cristian Жыл бұрын
Now I understand it better.
@deveshmaurya9101
@deveshmaurya9101 2 жыл бұрын
Thanks for posting
@damilaresamuelfagbenro1881
@damilaresamuelfagbenro1881 2 жыл бұрын
I have got a question. Is it possible to have the CanCaptureScreenshot binding with both classes in the service provider?
@LaravelDaily
@LaravelDaily 2 жыл бұрын
Why would you need that? How would Laravel then know which class to run?
@msdeav
@msdeav 3 жыл бұрын
thank you, sir..
@haroldpepete
@haroldpepete 3 жыл бұрын
Thank sr for share
@sale7680
@sale7680 2 жыл бұрын
Thank u 🙏
@jailsoncarneiro4936
@jailsoncarneiro4936 2 жыл бұрын
Show de Bola!
@glowiever
@glowiever 2 жыл бұрын
basically, php is like java in this regards
@fangfang3366
@fangfang3366 Жыл бұрын
We should say both of them follow OOP, even like c# LOL
@aymenmohammed2625
@aymenmohammed2625 3 жыл бұрын
❤😍
@devrajin5795
@devrajin5795 3 жыл бұрын
first viewer :D
@L-A-O-S
@L-A-O-S 3 жыл бұрын
Firster then video duration)
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 20 М.
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 16 МЛН
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Поветкин заставил себя уважать!
01:00
МИНУС БАЛЛ
Рет қаралды 7 МЛН
Laravel Security: Top 7 Mistakes Developers Make
11:16
Laravel Daily
Рет қаралды 84 М.
Laravel Eloquent: Deeper Relationships with One Query
10:37
Laravel Daily
Рет қаралды 141 М.
A Practical Example How To Use Interfaces In Golang
14:42
Anthony GG
Рет қаралды 25 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 199 М.
Faster Eloquent: Avoid Accessors with Foreach
9:35
Laravel Daily
Рет қаралды 53 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 208 М.
5 JavaScript Concepts You HAVE TO KNOW
9:38
James Q Quick
Рет қаралды 1,4 МЛН
How 1 Software Engineer Outperforms 138 - Lichess Case Study
22:28
Tom Delalande
Рет қаралды 57 М.
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 16 МЛН