Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Facades in Fuel 2.0
  • http://fuelphp.com/blogs/2013/08/2-0-an-update

    Hi, I have two questions.

    1. Why Facades are not a part of legacy support?
    2. The word facades is not proper, is it?

    I feel static method is a bit legacy. I don't need it. Does Fuel 2.0 recommend usage of static method interface? If so why?

    2.0's Facades are like Laravel's. And Laravel's facades are "proxies for service location" rather than facades pattern. Some people including me feels confusing or wrong that we call them facades. See http://www.brandonsavage.net/lets-talk-about-facades/

  • 1. We don't know yet, it's not ready at the moment.
    2. Possibly.

    If you don't need it, you don't have to use it.

    The 2.0 'Facade' classes don't contain any logic (the v1 static interface does). For some they are indeed only service locators, and for some they also contain the forge() method which is an instance creation helper. Because of the dependencies of some classes it simply removes a lot of the boilerplate of setting up your own instance manually.

    And a lot of the boilerplate is being moved into the ServiceProviders at the moment, so it could well be that a lot of the current 'Facade' classes are no longer needed. They however use the 'Facade' classes too, for the same reason.

    But then again, I think most people would still prefer to use View::forge() then all the lines of code behind that to create a view instance. I'm willing to bet that you're going to write helpers for that too, to abstract away the boilerplate code. And then you'll have your own static helpers...
  • Thank you.

    I also think static interface like 1.x is needed in 2.0, because of BC or for people prefer it for some reasons. And it is good to hear to use or not is my choice.

    But Facade is still bad naming. It implies 'Facade pattern'. But it seems to me that the pattern in 2.0 is not intended it. It is very confusing that we call something different same word.

    It was called merely 'static interface' in the past.
    > The static interface will continue to exist via a Static package and the
    Legacy add-on, but the purely OO usage is now the bread-and-butter of
    Fuel.
    http://fuelphp.com/blogs/2012/03/why-the-20-changes

  • It is still very much a work in progress, but I will imagine the current static classes will remain where they are for the time being.

    Once all service providers are setup and all injecttion factories are ready, all forge() logic should be in there, whicn means you only need a static interface to reach the DiC, and you can create all other objects through it. Then we can see how much (if any) of the static interface needs to remain.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion