Live data from Hacker News

Laravel 9

laravel-news.com

191–200 of 262 posts

Re: Laravel 9

#191
post #137

All else being equal, how do we feel about Rails 7 vs Laravel 9 in 2022? Giving the breadth of both frameworks I am pretty certain there has to be one objectively better choice. Which one is it? Why?

I don't think either is objectivly better - if for no other reason than ruby and php being quite different languages. Personally I much prefer ruby - but I could perhaps see myself reaching for Laravel for a project depending on requirements.

As a Ruby developer I resonate with this. I love a LOT about the Laravel ecosystem, but I also still really love Ruby and Rails.

Re: Laravel 9

#192
post #181

Earlier quoted context omitted.

Generally I use the model builder methods for this anyway, because I'm using the ORM and the models represent tables, so I barely ever build my own select statements at all. https://laravel.com/docs/8.x/eloquent

Even with an ORM, isn't there the risk of typing Flight::select('name') instead of Passenger::select('name'), if both values return the same data type (string)? Is that harder to do than accidentally typing `SELECT name FROM flights` instead of `SELECT name FROM passengers`? Aren't most of those issues found as soon as you first test the feature?

I don't understand the point you're getting at here. Isn't this kind of typo more or less universally possible? Which code library or generator can protect you from errors like this (and divine your intent?)

You can be protected from SQL injection and you can have various other query operations, and you can gain refactoring support (e.g. by telling the models the new table name), or you can add custom scopes that encapsulate transformations on the query.

Laravel also allows you to express model relationships, so Flight might have:

  public function passengers(): BelongsTo {
    return $this->hasMany(Passenger::class);
  }
and then you can do things like:

  $flight->passengers->where('name', 'like', 'XCSme%');
> Aren't most of those issues found as soon as you first test the feature?

I don't know.

The thing is, an ORM brings you other stuff (like a query builder integration) that allows you to construct queries without having to glue SQL strings together (and chain and pass query objects).

And Laravel separately also brings you a migration tool that allows you to encapsulate upgrades to your database as code snippets (so you can put code live without manually fiddling with SQL at all).

In my experience even really small apps benefit from this at some level. The discipline of using regular patterns like this is really useful.

(The Lighthouse GraphQL binding is where this stuff gets really interesting)

At any rate, we're unlikely to agree.

[edit: removed a tired-brain word choice mistake!]

Re: Laravel 9

#193

I thought Laravel was dead. Well looks like some people still like to use these slow and bloated frameworks. I cant say i miss the PHP ecosystem of bloat.

I'll take the bait.

Laravel is far from dead; it's more popular than ever. The older versions that you might be familiar with have seen a lot of improvements over the last couple of years. They're fairly aggressive with deprecating older versions of PHP, while still supporting LTS versions.

Its ecosystem is really flexible, and generally has great solutions for anything web-related with easy configuration. I haven't found Laravel to be slow when building websites, but we always put a CDN in front of it, so it doesn't really matter how fast or slow the framework is.

If you want a lighter-weight core to start with, there's Lumen, which is designed to be an API-only version of Laravel. Forget templates, just return JSON (or whatever).

Laravel is a great solution for a lot of websites and applications. Maybe not some applications you have in mind, and that's ok. Pick the right tool for the job. As someone who used to hate PHP, modern Laravel would be my go-to if I need a backend and can't simply get by with a static site generator.

Re: Laravel 9

#194
post #153
post #10

Laravel and Drupal 7+ frankly ruined PHP for me. PHP as a platform is KISS and elegant, and I still admire some of its features such as built in templating, filesystem based routing, etc. But whenever I look back at Laravel, I remember how dangerous overly complex fluff with a nice logo is to a platform.

> Laravel and Drupal 7+ frankly ruined PHP for me. You don't have to use either. It's like saying something like "Britney Spears ruined music for me". Just go with Symfony and be done with it.

Management routinely influences stack choice based on hype level.

Re: Laravel 9

#195
post #187
post #182

Earlier quoted context omitted.

Those files might work and your project might stay on that small scale - but you'd find it impossible to add automated tests to that. If your project grew to be serious enough to warrant automated testing then you're going to want to seriously refactor it and using a framework's dependency management is just going to make your life easier. You can make things a lot safer with just a little bit of separation and that…

It might be hard to do, but do you measure any KPIs (performance, codebase size, time needed to write a new feature, security) for before/after converting the platform to a different framework? I did switch the front-end side from no-framework (jQuery spaghetti) to a framework (React + MUI + TypeScript), but the main reason was that I needed: 1) Component reusability 2) Premade components (UI elements) 3) Data typing…

We don't specifically numerically measure them but we have seen our defect rate go down noticeably. The changes are also quite minimal with very little developer overhead being required - using a service architecture requires writing a factory and class definition once... using a query repository is about the same.

The biggest advantage we've seen though is in onboarding time. The more purpose driven and modular our code gets the quicker it is people pick up on each individual module types structure and new devs can start experimental coding quite quickly.

For me, personally, the ultimate attribute I value over everything else in a codebase is minimized maintenance costs - we have a few corners of our codebase that have extremely brittle automated tests that require hours of labour to execute the simplest of changes in and they're on our fix list. But the stuff we need to change frequently can be changed quickly and safely so our bug fix turn around is relatively minor. I'm actually in the middle of upgrading us from ZF2 to Laminas and this work is probably going to last about three weeks (with a bunch of the most annoying fixes coming out of Doctrine and their fanatical devotion to `final`ing every class under the sun - thanks guys) which honestly seems extremely reasonable to me for bumping two framework versions.

I'm also really not personally a fan of ORMs because the query building tends to make DB performance harder to tune and I loathe the performance implications of ActiveRecord approaches - but they're components I've built into our infrastructure to support other devs and I can comprehend their appeal.

Re: Laravel 9

#196
post #178

Earlier quoted context omitted.

There’s definitely an overhead in updating your codebase to work with new versions of the framework but the time saved by not having to write all the features yourself makes it worth it.

Can you give example of some features that you have to write that don't exist in a plain PHP application nor an external library (i.e. features that have to be tightly integrated in the core of the product)?

To be honest, I'm sure all the features of Laravel I use could also be done with external libraries, but researching and finding something suitable, hooking it together, configuring, integrating it into my project is something I am unwilling to spend time on.

I write code to solve problems for my company, so building a framework is very low on my priorities. I'd rather just use something that is ready on day one.

Maybe it's not to everyone's taste but I like the fact I can just get on with trying to build my product.

Re: Laravel 9

#197

Earlier quoted context omitted.

I love hearing about developer experiences by solo devs. As a potential solo dev, I was actually looking to go the Spring Boot route. I think Java has gone in a better direction the past few years, and I prefer it over PHP due to static typing, functional programming (to a point), and the tooling. Spring Boot seems to provide a lot of the same development productivity. My only other experience is with Rails and Djang…

I also find these decisions very hard. I switched from NodeJS to Spring Boot some 5 years ago when I found that the JS community moved faster than my clients could pay me to keep up to date. It has been great to make apps in Java with Thymeleaf, until I wanted to add dynamic frontends (a lot of advantages vanished) or when I tried to put Java on my CV. I am now considering switching to .NET and Angular. I would be ha…

Hey that's fantastic. I'd love to hear more! You went 5 years in the direct direction I want to go (Spring Boot + Thymeleaf). I'm a bit confused why you were having difficulty finding work with Java. Seems like there's a lot of Java work out there.

Re: Laravel 9

#198
post #90
post #65

Earlier quoted context omitted.

But what if the app is a simple monolith that exposes some API routes and processes/reads/stores data in a database? Is something like this really harder to understand for a new developer than a Laravel project? .htaccess dbconfig.php /api /users create.php get.php getAll.php delete.php /products create.php get.php delete.php And where each file does something like (simplified) // /api/users/getAll.php include 'dbcon…

If I am working alone, I sometimes do similar stuff. But if I am working with others, I don't really want to deliberate over every new architectural decision if a project grows. I want to be able to say, "Hey, can you make a new storelocator page" and then they can get it done using the docs. They know where models, controllers, views live, they know how to make migrations for the new tables, they can even google "st…

I took over an enormous system that a third party developer built in Laravel.

Not good code, particularly, and not particularly good database design.

Also no documentation really.

But the implementation was pretty clearly pure Laravel, and the migrations ran without issue. So that was immediately a huge weight off my mind, because I knew I would be able to maintain the live, stage and dev boxes sanely.

The two biggest problems with this app were

1) the number of places they diverged from using the query builder for no really good reason when scopes could have made everything so much more readable

2) a false assumption they made about subquery ordering in MySQL (implicit ordering that worked for them in 4.x but would not work in 5.x, something along those lines anyway)

Because of 1), 2) was incredibly painful to fix. Dozens of bits of arbitrary SQL that could have been handled by the query builder.

And I'm sure the only reason it's like that is because that's the way they started out and they had time pressure that stopped them ever changing course.

Expedience kills software.

Re: Laravel 9

#199

Earlier quoted context omitted.

This is my experience with Laravel as well. Laravel looks great on the surface for a simple CRUD application, but once you need to do something non-trivial with it, you need to start fighting the framework. Also I dislike the large amount of magic happening within the framework. I want to understand what the code is doing, so that I can properly debug it in an emergency. As a specific example I needed to override hal…

Exactly this for the exact same reasons, only more specific to the Eloquent ORM instead. God forbid you need to do nested-nested-nested relationships or something relatively complex. Laravel works VERY well for the simple cases, but all the weak typing, reflection and runtime searches that it uses just makes every runtime framework problem a pain in the ass to debug. I'll stick to Spring Boot or ASP.NET Core any day.

I don't know if many share the same sentiment, but mine is to keep ORM use to the simplest of query. Anymore complex than that is better to be developed with raw queries, which also usually supported by the ORM.

Re: Laravel 9

#200
post #31

Anyone know if/when they'll push these changes to their micro-framework Lumen ( https://lumen.laravel.com/ )?

My sense is Lumen's eventually going to go away, with the heavier built-in stuff moved into optional packages like the starter kits at https://laravel.com/docs/9.x/authentication#authentication-q... .

I really, really need to look at Breeze and Jetstream.
Post reply on HN