Laravel 11: New Slim Base Controller with No Traits

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 24

  • @ikarolaborda726
    @ikarolaborda726 9 месяцев назад +4

    Laravel 11 is closer to what Symfony Skeleton has been delivering for some years, yet it still maintains the fancy laravel way of doing things, just adding the “use only what you need, when you need it” philosophy. I like that…

  • @MzungaElephant
    @MzungaElephant 8 месяцев назад +2

    I was skeptical about this change, watching this I'm not sure why, cheers 👍

  • @sawood2010
    @sawood2010 9 месяцев назад +1

    I like the changes. I started using a "Gate" idea in my APIs to reinforce keeping controllers as small as possible. Assuming the request has all of the right permissions it is then passed on to the right class to retrieve data.

  • @JJ15ASMR
    @JJ15ASMR 9 месяцев назад +4

    Interesting, especially about the "$this->validate()" syntax. I've used it a lot in quite small, usually invokable controllers since first learning Laravel, but I see how "$request->validate()" is more streamlined and explicit.

  • @Fanmade1b
    @Fanmade1b 8 месяцев назад +1

    I usually create single responsibility controllers with just one __invoke method and almost never even extend any base controller.
    It works just fine.
    I wasn't even aware (anymore) of these traits :D
    If I want to validate the request parameters, I create a specific (form-)request class.
    Authentication is done in middleware and authorization using gates, policies or similar functionalities. This is often even done inside the action classes called by the controller.
    Doing too much in the controllers is usually a bad sign anyway.
    I mean, of course I sometimes do everything in a controller (or even in a callback directly in the request definition), but that's only for very simple logic or PoCs.
    So while I'm not (yet?) happy with all the changes to Laravel 11, I do like this one.
    But that's all subjective, of course :)

  • @jonashansen2512
    @jonashansen2512 9 месяцев назад

    👋I used to use the older syntaxes and still have some controllers that haven’t been touched in years.
    I used to prefer using string aliases bound in the app container for the portability, can just yank & paste snippets without thinking about import stmts.
    With the introduction of real-time facades, additional testing features like mock and spy, and resolving in global namespace thru aliases I’m now defaulting to Facades.
    I think the overhead is worth it.
    An extra feature I have yet to use, but is nice to have, is being able to override a facade alias once and have it automatically effect everywhere

  • @spicynoodle7419
    @spicynoodle7419 9 месяцев назад +1

    Nice, this can save some space in the opcache buffer

  • @ihorrud5088
    @ihorrud5088 9 месяцев назад

    Thanks, something new today.

  • @AbderrahmanFodili
    @AbderrahmanFodili 9 месяцев назад +7

    It's evolving
    Just backwards!!

  • @mdismailhossain2219
    @mdismailhossain2219 6 месяцев назад +1

    also $this->middleware('can:is_admin') check in controllers will not work by default

  • @saravanasai2391
    @saravanasai2391 9 месяцев назад +1

    The Gate is so clear now. Because I face once in a project which policy does it use.. Where it is configured

  • @danielsmartins6696
    @danielsmartins6696 7 месяцев назад

    Please i need help with $this->middleware(), it was removed in laravel 11. what traits do i need to import to be able access the $this->middleware() in laravel controllers

    • @LaravelDaily
      @LaravelDaily  7 месяцев назад

      I would prefer to specify middleware in the routes, as much as possible.

  • @GergelyCsermely
    @GergelyCsermely 9 месяцев назад

    Thanks!

  • @shubhamsahuSD
    @shubhamsahuSD 8 месяцев назад

    🎉🎉❤

  • @KiranShrestha4801214
    @KiranShrestha4801214 9 месяцев назад

    Love From Nepal

  • @maximilianominetto524
    @maximilianominetto524 8 месяцев назад

    For me it is better solution, the code should reflect the intention of the programmer not magic.
    Regards.

  • @underflowexception
    @underflowexception 8 месяцев назад

    I dont like how laravel hides the underlying logic makes it harder to debug issues
    All the interfaces should be there by default and if you want to remove it then go for it
    Release aftee release the framework just gets more bloated

  • @lukmauu
    @lukmauu 9 месяцев назад +1

    I did not like 11 at all, I think Laravel is getting too mysterious and magical. We need more clear code no magic

    • @MarkSnape
      @MarkSnape 8 месяцев назад

      what you don't need is 6 ways to do something, but they all exist in order to make upgrading legacy projects easier. We are going to need to see more things deprecated unfortunately.