News for hackers. Stuff that matters.
Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @08:13AM (#34411985)
Looking at the Laravel site, I’m concerned about Laravel’s reliance on an ORM. Not only because ORMs are widely derided, but because I have a legacy MySQL DB and PHP 5 project I want to resurrect. I’m down to rewrite the server, but how do I restore a database full of user data with Laravel?
Re:PHP in 2023 by jt2190 on Tuesday January 17, 2023 @08:29AM (#34412126)
Laravel is “linked” together via a combination of Composer dependency manager and Dependency Injection. You can easily customize your setup to remove the dependency on Eloquent ORM and use something else.
Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @08:33AM (#34412163)
Thanks!
Re:PHP in 2023 by spiderfarmer on Tuesday January 17, 2023 @08:17AM (#34412016)
What I'm doing is recreate everything the Laravel way and worry about importing the data (millions of pictures, videos and comments) later. I figured that once I'm proficient at Laravel that writing some import jobs would be relatively easy.
Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @08:19AM (#34412034)
Thanks! That’s happens to be just what I need to do: import pictures and related data.
Re:PHP in 2023 by cellover on Tuesday January 17, 2023 @08:24AM (#34412076)
Does your DB have a classic design? You can very easily map an existing DB with a fresh Laravel install, just write a couple Models, their relationships and you're almost set.

I have been working with Laravel on a daily basis since 6 years and have never felt more efficient with code.

Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @08:32AM (#34412153)
Not sure what you mean by classic, but I designed it manually to be queried with plain SQL. So I suspect the answer to your question is yes.

Thanks for the info!

Re:PHP in 2023 by cellover on Tuesday January 17, 2023 @09:50AM (#34413019)
By classic I mean something somewhat standardized like user table: id, name, email ; post table: id, user_id, content etc.
Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @02:43PM (#34417637)
Pretty much, then, yes.
Re:PHP in 2023 by pocketsand on Tuesday January 17, 2023 @09:22AM (#34412662)
I work on a project like this and you'll run into some papercuts, but it's not hard.

You can take a model for anything in your legacy code, and just set properties on the model to teach Laravel how to deal with things that don't follow conventions.

For example, you can override the table name. Suppose you had a legacy table called "postdata". In Laravel, this table would be called posts, and a model would be Post.

So you'd just tell Post to query postdata rather than posts.

Likewise, you can tell it which fields to cast as dates, booleans, etc. You can tell it which fields represent timestamps for updating, creating, deleting and so forth.

You can setup relations that don't follow naming conventions the same way.

The only issue I've run into is doing things like setting up relationships across databases. You can do it, it's just not super straightforward.

I think you'll find it's a breath of fresh air to have a modern wrapper around your legacy code, and that your legacy stuff will then fit in quite nicely with your new work.

Re:PHP in 2023 by BuckyBeaver on Tuesday January 17, 2023 @02:41PM (#34417596)
Great, thanks! I’m pretty psyched to get started, after reading these comments.