Next up is @christophrumpel talking about Service Container.

Thread ๐Ÿงต
Cool animation on slides.
Dinner break ๐Ÿ˜” can't live-tweet ... Just listening ๐Ÿ˜…
$this->app is Container instance. Available to every ServiceProvider.

Laravel will automatically resolve the bind'ed class from Container if you ask for this in a Controller method let's say.
p'an p'an paam ๐Ÿ˜‚

Switching to Paddle

New payment provider is added. For Paddle.
PaymentContract for all Payment Providers in the app.

Both StripePaymentProvider and PaddlePaymentProvider will implement it.

Inside controller method we will require only the contract and Laravel will return a concrete implementation.

another paymentprovider can be added too.
Binding the interface to concrete implementation inside ServiceContainer is really powerful.

Laravel framework follows this pattern to provide different drivers for the same functionality, like Database.

MySQL, PgSQL and so on.
Why we need ServiceContainer?

Changing the control from down there to up here.
Explicit binding and Facades.

In the back, every Facade asking for a class from Service Container.

One issue with Facade: You don't see every dependency for the class. But with constructors you can easily see dependencies for each class.
Fakes are used in tests.

Let's assume we want to work with Mail.

Mail::getFacadeRoot() method returns instance of underlying class which is MailManager ( okay, i didn't know it seriously)

Mail::fake() returns different instance than MailManager.
Facade::fake() calls swap() method.

Now let's fake the PaymentProvider. Woah!
PaymentFake is a custom class.

This is awesome. Make a fake class and bind it inside a fake() method on the actual class.
@christophrumpel uses Postmark to send transactional emails in his blog, I think?

$headers = []; //contains headers to send to Postmark

Override Laravel's base MailManager class. The overriden class can be introduced to Laravel by changing it inside MailServiceProvider.
We are able to extend the content/modify the content that's already been bind to Container. Pretty Amazing.
Singletons. Lots of ServiceProvider use it.
I think I shared this example few days ago ๐Ÿ˜…
Why we need Service Container in Laravel. It's special!
Resources to learn more about Service Container.
Course by @christophrumpel
New course by @christophrumpel about @phpstorm

Website is live now: masteringphpstorm.com
End of @christophrumpel talk.

End of thread.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Zubair Mohsin

Zubair Mohsin Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Zubairmohsin33

17 Mar
Next up we have @enunomaduro on @LaraconOnline

He'll be telling us about Artisan Console Component

Thread ๐Ÿงต
Image
Few projects of Nuno running on Artisan console component. ImageImage
Read 19 tweets
17 Mar
Next up we have @calebporzio talking about @LaravelLivewire and @Alpine_JS

Thread ๐Ÿงต Image
of Livewire. Woah! ImageImageImage
Show the small things, instead of big things.

Shoutout to @TransistorFM and @noplanstomerge Image
Read 26 tweets
17 Mar
Next up we have @m1guelpf on @LaraconOnline

He'll be talking about Laraveil Illuminate Foundation

Thread ๐Ÿงต
Image
laravel/framework requires micro packages namespaced under Illuminate. ImageImage
Read 17 tweets
17 Mar
Next up we have @marcelpociot

He'll be talking about Laravel Broadcasting on @LaraconOnline

Thread ๐Ÿงต
Follow along at laracon.beyondco.de

It contains some interactive examples.
Two components involved in Broadcasting. Just the communication between Laravel Backend

Everytime you shoot the shoot button confetti's happen in real-time. ( laracon.beyondco.de ) ImageImage
Read 25 tweets
17 Mar
Next up, we have @taylorotwell on @LaraconOnline

Thread about keynotes from Taylor's talk.

๐Ÿงต
Thanking everyone ๐Ÿ˜…
Stupid internet got disconnected. Alright, we are back on.
Read 38 tweets
17 Mar
Next up we have @bobbybouwmann who will be talking about Laravel Router.

Thread ๐Ÿงต
And now he's updating Zoom in the background ๐Ÿ˜‚
That's a good menu
Read 33 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!