flugg / laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal with Laravel's elegancy.
MIT License
862 stars 87 forks source link

Support Laravel 5.5 resources #71

Open nasyrov opened 7 years ago

nasyrov commented 7 years ago

Hi @flugger,

Have you seen https://laravel.com/docs/5.5/eloquent-resources? If so, would you consider to release a new package version that leverages that new feature?

Cheers, Evgenii

flugg commented 7 years ago

Hey!

Yes, I've been looking into the 5.5 resources and feel they're a step in the right direction, however, they currently don't provide the same feature-set as Fractal. The only really unique feature of the 5.5 resources is the conditional attributes and I will be looking into supporting this in the near future.

I've been tinkering with ways to combine them to get the best of both worlds, but they don't really play well together and it would probably be more efficient to just use the 5.5 resources and rewrite some of Fractal's features on top of it. However, I feel like this package is in a really good state after a recent major rewrite and I'm thinking I'm gonna give the 5.5 resources some time to adopt before I head into a new rewrite.

One crazy idea that just crossed my mind though; I suppose I could rename Transformer to Resource and move it into the Http folder for a 3.0 release to make it feel more like 5.5. But the 'resource' name do kind of collides with Fractal's own concept of a resource..

nasyrov commented 7 years ago

Sounds reasonable! Let it steep for some time... The one thing I'm afraid of is that you can keep up with the laravel features like conditional fields but I'm pretty sure there will be more features introduced with time and you will have to basically duplicate the code...

flugg commented 7 years ago

I'll leave this issue open and think some more about how to best support resource objects.

iamroi commented 5 years ago

Hi @flugger,

Is there any update on this? It would be awesome to make use of eloquent resource functions.

flugg commented 5 years ago

I'm currently building a laravel application where I'm using eloquent resources, in an effort to learn more about them and see how they would fit into this package. So I'm definitely keen on finding a solution for this, but I'm afraid it requires a major rewrite. I'll keep you updated :)

flugg commented 4 years ago

@nasyrov @mrajabtech I have some updates I would like to share - the last couple of weeks I've been hard at work rewriting the package to support API resources and discard Fractal altogether. This has allowed me to simplify the code a lot and I believe the package has a clearer focus and is easier to use while keeping the core of the package the same. Most of the open issues will be solved with this release. If anyone has any requests for the new version, please let me know. I expect to have it all ready before 2020 🙂

iamroi commented 4 years ago

@flugger Fantastic!! Can't wait to play with the new release :100:

nasyrov commented 4 years ago

Hi @flugger sounds exciting!

iamroi commented 4 years ago

Hi @flugger, do you think we are close to see the eloquent resources switch?

I see there is a branch feature/api-resources, is it stable enough to use it in my application?

flugg commented 4 years ago

@iamroi Hi, we are close indeed! Things have slowed down a bit the past month, but I'll put some effort into finishing the version soon :)

I don't think the branch is stable enough to use in production yet, but would love some feedback, so feel free to use it and tell me what you think. It's a complete rewrite of the package and I've been a bit hesitant to release it as I want to make sure people will be happy with the changes.

aubreychiduku commented 4 years ago

Hey @flugger great looking package - thanks! I've been looking for something that incorporates Laravel resources.

I've just tried to install what will be v4.0 but i'm getting a class not found error for Flugg\Responder\Http\Responses\Decorators\StatusCodeDecorator

Output

Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals

flugg commented 4 years ago

Hey @iamroi and @aubreychiduku , sorry for the delay on the new version and the problems in the "alpha" version - have been some busy months and want to get it perfect before I release it. Have had quite some time to work on it the couple past weeks and I must say, the end result is looking better than first anticipated. I'm very happy with the direction the package is heading and it should be ready for release sometime soon. I'll see if I can push the latest changes once I hit the next milestone and the tests pass.

With that said, I'd love to share some of the highlights of the new version:

And all of this with the same API as before and a 40% reduction of code allowing for a more concise code base. It also currently has 100% test coverage. Hope you're all as excited as I am!

iamroi commented 4 years ago

Omg this is soo exciting!! Thank you for finding time to work on this in your busy schedule. I can't wait to try the new features :) Hope I can contribute in some way!

Hesesses commented 1 year ago

Hello!

Found this "issue" and wondering is the new version still alive? :)

flugg commented 1 year ago

Hi @Hesesses,

I've been eagerly awaiting its release for quite some time. However, since I'm not actively using PHP in my day-to-day work, finding the time and motivation to complete the final steps has been challenging. The package is almost finished, and to the best of my knowledge, it should work flawlessly. You can find the code and updated documentation in the api-resources branch. To be transparent, here's the remaining to-do list that I haven't touched in a year or two:

As you can see, the project is nearly complete. However, since it has been a while since I delved into the code, it will take some time to familiarize myself with it again. My plan is to run the new version on a fresh Laravel installation and thoroughly test that everything functions as intended. I welcome any contributions from the community, and I'll make an effort to allocate time soon to address the remaining tasks.

Hesesses commented 1 year ago

Thanks @flugg for the update.

I'm planning to start a new project in few weeks and I will give a try for the new version. I have never been working with a package, but I will test as much as possible and give feedback 🙏

Hesesses commented 1 year ago

Do you have any ideas why installing the branch does not work with composer?

composer.json

"flugg/laravel-responder":"dev-feature/api-resources",
...
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/flugg/laravel-responder"
    }
]

Your requirements could not be resolved to an installable set of packages.

Problem 1