danrot,
@danrot@mastodon.social avatar

Currently looking into #Laravel for my new job.

danrot,
@danrot@mastodon.social avatar

The best thing about #Laravel so far is the absence of #XML and #YAML files. All configuration I've seen so far is happening in #PHP files using fluent interfaces.

syntaxseed,
@syntaxseed@phpc.social avatar

@danrot I use #Symfony & the #YAML config totally bothers me. I switch to the #php style whenever possible but it makes sample code hard to find because it's not the default. 😓

danrot,
@danrot@mastodon.social avatar

@syntaxseed Totally agree. I know they made some progress in that regard, and I would also always use the #PHP configuration.

But all summed up I would still prefer Symfony for now by a lot. Additionally to all that magic stuff that breaks IDEs it also has eloquent, which doesn't allow for a cleanly separated domain model.

danrot,
@danrot@mastodon.social avatar

The worst thing about #Laravel so far is the heavy usage of static and magic methods. Already took me quite some time to find a test failing only when all tests are run, which was caused by caching something on a static variable (not in #Laravel though). And for IDEs to work correctly multiple _ide_helper files are necessary, and even then it is not always working.

Crell,
@Crell@phpc.social avatar

@danrot There's only 2 things about Laravel I like: The use of all-PHP config, and Laravel Shift.

I basically hate everything else about Laravel.

danrot,
@danrot@mastodon.social avatar

@Crell out of curiosity: did you already work on many #Laravel projects? I think the biggest problem is eloquent, but I am trying to go open-minded into this 🙈

Crell,
@Crell@phpc.social avatar

@danrot I inherited a half dozen Laravel projects at $dayjob last year, and we've been working to update them. I went in knowing its reputation but trying to be open minded. I regularly find things I hate, but facades and Eloquent are at the top of the list.

Eloquent isn't an ORM. It's a bad query builder wrapped into static classes, because we're still in PHP 4 land.

danrot,
@danrot@mastodon.social avatar

@Crell I was already thinking if #Laravel would be nicer to use if you just would not use eloquent, but from the documentation pages I've read until now I've got the feeling that it is so deeply integrated that it might be hard to do so.

Crell,
@Crell@phpc.social avatar

@danrot In theory it's possible, but what you would have left at that point is basically a badly-designed Slim, so may as well just use Slim.

chris,

@Crell do you have a mastodon-sized take on facades? Most anti-facade sentiment I see is from (often junior) devs who are so excited about SOLID that they can’t wait to tell you about how any specific thing doesn’t meet their understanding of those principles. But I know you’re obviously not in that camp. Are you opposed to service location in general, or something about facades, in particular?

Crell,
@Crell@phpc.social avatar

@chris

  1. Service locators are bad, m'kay?
  2. 4 layers of magic method indirection makes step-debugging almost impossible.
  3. All testing is 10x harder, and slower as you need the whole kernel and container rather than just passing a constructor dependency like an adult.
  4. IDEs can't handle it without extra (non-bundled) packages to teach it how to understand Laravel, which then confuses auto-complete.
Crell,
@Crell@phpc.social avatar

@chris

  1. They're often named the same as the class they front for, which makes using both in the same file harder. (Need to alias one or the other.) This is especially an issue for, say, Request.
thgs,
@thgs@phpc.social avatar

@Crell @chris Personally there are a bunch of things I dislike about Laravel, although I really liked it in the beginning but these days.. I mostly dislike that Symfony tries to have the same features, or equivalents that are close in functionality but in the Symfony way :)

chris,

@Crell hm. I agree with 2, 4, and 5 generally.

I think once you’re used to how facades work, stepping thru them quickly isn’t that hard, but it’s annoying. And IDE support is mostly solved with docblock annotations, but it would be nice if that wasn’t necessary. The naming issue sucks.

As for 1, I would counter that it depends :) In most library-type code, accepting dependencies in the constructor is obviously better.

Crell,
@Crell@phpc.social avatar

@chris I could see an "It Depends" argument pre-8.0. With CPP now, just listing your dependent services is so amazingly easy, and self-documenting, that there's no excuse to do anything less. (Assuming you have an autowiring container, which these days is all of them.)

chris,

@Crell I think http controllers are different. I just peeked at our codebase and nearly all facade usage happens in controller actions. IMHO calling a facade in update rather than adding a constructor, adding the promoted argument, then going back to the update method and calling $this-> makes the dependency LESS obvious.

Maybe it’s that there’s certain code that will never make sense outside of the fully-booted-app context, and I think the trade-offs are different in that code.

Crell,
@Crell@phpc.social avatar

@chris I'd agree with the latter, up to a point.

That said, at this point I'm of the mind that "big controllers" with a half dozen or more actions on them are a bad design choice anyway. Single-__invoke() controllers are just... nice. (And then listing your dependencies is trivial; you may not even need to scroll.)

chris,

@Crell yeah, I don’t mind the occasional big controller, but I think they’re often a smell. But even a pretty focused RESTful controller benefits from a facade here or there, imho.

And if things get out of hand, any code that I pull out into dedicated classes are going to use DI rather than SL.

Only outlier is auth, where relying on a globally-available “current user” is sometimes so much nicer than injecting the guard and fetching the user each time. Even if it bites you once in a while 🤷‍♂️

Crell,
@Crell@phpc.social avatar

@chris I will grant certain request global things, like current user or current request, can get tricky. But we should still try.

chris,

@Crell I also feel like facades are so so so much better than global $user which is where much of my early PHP career was spent 😅

shawnhooper,
@shawnhooper@fosstodon.org avatar

@chris Ugh. PHP globals. Don’t miss using those! Ahem, WordPress.

@Crell

Crell,
@Crell@phpc.social avatar

@chris They're really not. 🙂

Konafets,
@Konafets@norden.social avatar

@danrot @Crell Why is Eloquent the biggest problem?

danrot,
@danrot@mastodon.social avatar

@Konafets @Crell because it makes it basically impossible to develop a domain model that is separated from the framework.

Konafets,
@Konafets@norden.social avatar

@danrot @Crell Thats true as Eloquent follows the ActiveRecord pattern. From my experience creating framework agnostic domain models is an academic exercise without any relevance in daily business. I never had a customer request to use their framework agnostic domain models of framework A and insert it in framework B.

Crell,
@Crell@phpc.social avatar

@Konafets @danrot It's more that it makes testing harder. Framework agnostic code isn't (usually) about migrating frameworks, it's about keeping your components loosely coupled and so easy to test and modify.

Konafets,
@Konafets@norden.social avatar

@Crell @danrot Which problems did you face with Laravel models?

Crell,
@Crell@phpc.social avatar

@Konafets @danrot

  1. Everything is static methods, which means you need custom, proprietary global variable hacks to test anything.
  2. Mocking a data object is hard to impossible.
  3. The list of properties/types of an object does not exist in code, so even knowing what the fields are (either you or SA tools) is impossible without examining the DB.
  4. Arrays. Arrays everywhere.
  5. Magic methods 4 layers deep.
  6. Inheritance trees 4 layers deep.
    ...
Konafets,
@Konafets@norden.social avatar

@Crell @danrot

  1. Do not know what you mean with global variable hacks. Example?
  2. you mock you object and add it to the DI container https://laravel.com/docs/9.x/mocking#mocking-objects
  3. A CLI cmd examines the DB and generates a static file for you and your IDE
  4. How they affect your testing?
  5. How does it affects your testing?
Crell,
@Crell@phpc.social avatar

@Konafets @danrot

  1. Every static method that sets some state is a global with extra indirection.
  2. So virtually every class is untestable without a live container. This is Bad(tm). Full stop.
  3. Yes, I use it. It kind of works. But still doesn't help me in reading the code to know WTF is going on.
  4. PHP is a typed language. Arrays defy meaningful types and static analysis. cf: https://www.youtube.com/watch?v=nNtulOOZ0GY&list=PLAi1rj7b0ApWScH6njlptekH-WjohZ3zs&index=2&t=152s&pp=gAQBiAQB
  5. Ibid.
  6. Ibid.

You cannot statically comprehend Laravel. This is bad.

Konafets,
@Konafets@norden.social avatar

@Crell @danrot That all sounds like you want to develop your code beside the framework which is fine but Laravel is not made for this.

Crell,
@Crell@phpc.social avatar

@Konafets @danrot Laravel is a throwback to PHP 4 era frameworks. It's three PHP 4 functions in a trenchcoat, not a modern OOP framework.

It clearly works for some people, but I find it horrible and will steer people toward better options whenever I can. It teaches all the wrong things to do in PHP.

Konafets,
@Konafets@norden.social avatar

@Crell @danrot What is a better option in your opinion?

Crell,
@Crell@phpc.social avatar

@Konafets @danrot Both Symfony and Slim do a much better job of supporting modern good practices. I have my issues with both of them as well, but nothing as fundamental as Laravel's flaws.

I haven't used Laminas recently enough to have an opinion.

danrot,
@danrot@mastodon.social avatar

@Konafets @Crell Currently regularly facing another problem with eloquent models: They are a nightmare to debug. Instead of just seeing an objetct with its properties I have to go and find the attributes property amongst many others, which makes debugging unnecessarily hard...

Crell,
@Crell@phpc.social avatar

@danrot @Konafets Yeah, Laravel is actively hostile to standard debugging techniques, IME.

danrot,
@danrot@mastodon.social avatar

@Konafets @Crell Sounds to me like you are working for an agency or something similar. IMO it makes sense to separate your business logic from your framework if you are building a long-living product like a SaaS. I've seen cases where none of the business logic could be reused when moving from an abandoned framework, because it was so tightly coupled and the replacement works differently.

Konafets,
@Konafets@norden.social avatar

@danrot @Crell Nope, I am self employed.

Yeah, in theory it makes sense but in real world the landscape of ORM in frameworks is scattered. Symfony uses DataMapper (DM), Laravel ActiveRecord (AR), CakePHP a mixture of both, TYPO3 some sort of DM, CodeIgniter uses AR, Yii uses AR. So now tell me to which framework you want to migrate?

Crell,
@Crell@phpc.social avatar

@Konafets @danrot So what you're saying is the PHP ecosystem kinda sucks at data storage libraries. I will totally buy that. 🙂

Konafets,
@Konafets@norden.social avatar

@Crell @danrot Exactly. You will reimplement your framework agnostic model in the new framework again.

thgs,
@thgs@phpc.social avatar

@danrot @Konafets @Crell you ccould map from the eloquent models to your entities though. and keep the eloquent models a convenience for the repository implementation

Crell,
@Crell@phpc.social avatar

@thgs @danrot @Konafets Or I could use a proper data mapper ORM that already does that for me and doesn't pollute my code with static method calls.

thgs,
@thgs@phpc.social avatar

@Crell @danrot @Konafets

Let's simply agree that it's a matter of what kind of pollution you want to deal with.

The pollution of static classes, the pollution of persistent collection or the pollution of purity itself.

Crell,
@Crell@phpc.social avatar

@thgs @danrot @Konafets "Pure functional languages have this advantage: all flow of data is made explicit. And this disadvantage: sometimes it is painfully explicit." --Phil Wadler

bobmagicii,
@bobmagicii@phpc.social avatar

@thgs

> pollution of purity itself

new band name i called it.

thgs,
@thgs@phpc.social avatar

@bobmagicii

can i play the keyboard?

bobmagicii,
@bobmagicii@phpc.social avatar
danrot,
@danrot@mastodon.social avatar

@thgs @Crell @Konafets In #Symfony there is no pollution of static classes and I don't know what you mean by pollution of persistent collection. And I currently cannot see how #Laravel helps with any of these pollutions, the way I see it, it even embraces them.

thgs,
@thgs@phpc.social avatar

@danrot @Crell @Konafets

Yes, sorry to confuse. I was referring to Crell's comment about a proper data mapper ORM. Laravel does pollute with static classes you are right. The other mentioned pollutions come from other ORMs.

I believe we are all in the same page about the pollution.

danrot,
@danrot@mastodon.social avatar

Another thing I am really missing in #Laravel: Something like the #Symfony profiler. Getting information like which queries are executed or which events are dispatched always seem to need some code being manually added. IMO a framework should log this information somewhere by default if it is run in the development environment.

theiNaD,
jasonmccallister,

@theiNaD @danrot definitely a fan of Telescope for this use case. It has really good integration for all things Laravel (including commands and mail)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Laravel
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • tester
  • tacticalgear
  • ethstaker
  • normalnudes
  • cisconetworking
  • cubers
  • Durango
  • Leos
  • provamag3
  • modclub
  • anitta
  • JUstTest
  • All magazines