0

I know that my question is possible duplicate of What is Facades used in Laravel?.

But please consider this as a different question.

I need a simpler explanation to this.In my best understanding, FACADES ARE SHORTCUTS.

Am I right?.

ktaro
  • 413
  • 1
  • 7
  • 24

1 Answers1

1

Facades are not shortcuts.

Consider that you bought a new computer. You install various applications.

You put frequently used apps on your screen so whenever you need them you can use them. You need word: you opened word from shortcuts, you need photoshop you opened from shortcuts. However you don't open word to edit photos or Photoshop for editing documents. These are shortcuts a.k.a aliases in Laravel

On the other hand; You installed a screenshot app to your computer. You wanna get screenshots from word files and screenshots from photoshop as well as from various other applications on your computer. So this screenshot app is something you use in various applications. This is what called facades in Laravel.

More technically; For example you can use Requests often in many different places of your application so making an alias for Requests saves you time. However you don't really need to pass requests to your models. However you might need to check user roles in controller or in models even in view files... So Requests are defined as alias and while Roles are facades. Hope it makes sense

Anar Bayramov
  • 11,158
  • 5
  • 44
  • 64
  • Thanks @Anar.But Im stil confuse.I posted the same question in another forum and somebody said '**Yes.Facades are shortcut to instances bound in the container**'. – ktaro Oct 16 '18 at 08:10
  • Now I understand. Thanks @Anar. :D – ktaro Feb 19 '19 at 01:36