cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
778 stars 109 forks source link

Migrate from cloudcreativity/laravel-json-api to laravel-json-api/laravel #632

Closed veneliniliev closed 6 months ago

veneliniliev commented 2 years ago

I want to migrate from cloudcreativity/laravel-json-api to laravel-json-api/laravel.

I have too much code that I don't want to migrate when starting a new laravel project. Can I install both libraries in one project?

I have a problem with one dependency library that is different version laravel-json-api/encoder-neomerx

Problem 1
    - laravel-json-api/laravel[v2.0.0, ..., 2.x-dev] require laravel-json-api/encoder-neomerx ^2.0 -> satisfiable by laravel-json-api/encoder-neomerx[v2.0.0, 2.x-dev].
    - laravel-json-api/encoder-neomerx[v2.0.0, ..., 2.x-dev] require laravel-json-api/neomerx-json-api ^5.0 -> satisfiable by laravel-json-api/neomerx-json-api[v5.0.0, 5.x-dev].
    - You can only install one version of a package, so only one of these can be installed: laravel-json-api/neomerx-json-api[v1.1.0, v1.x-dev, v5.0.0, 5.x-dev].
    - cloudcreativity/laravel-json-api[v4.0.0, ..., 4.x-dev] require laravel-json-api/neomerx-json-api ^1.1 -> satisfiable by laravel-json-api/neomerx-json-api[v1.1.0, v1.x-dev].
    - Root composer.json requires cloudcreativity/laravel-json-api ^4.0 -> satisfiable by cloudcreativity/laravel-json-api[v4.0.0, 4.x-dev].
    - Root composer.json requires laravel-json-api/laravel ^2.0 -> satisfiable by laravel-json-api/laravel[v2.0.0, v2.1.0, 2.x-dev].

@lindyhopchris Is there a possibility that this will happen?

lindyhopchris commented 2 years ago

It's actually worse than that - laravel-json-api/laravel relies on ^5.0.

This has actually been discussed on Slack. I agree it would be really useful to be able to install both the old package and the new package - and the only blocker to doing that is the Neomerx dependency.

So yes, I think it would be useful to do this upgrade in the old package to unblock this. However, I don't really have a concept of how long that'll take, as it's bit of an unknown quantity as to how big the change is.

veneliniliev commented 2 years ago

I think it would be quite convenient for people like me to migrate to the new version.

i tested with "laravel-json-api/laravel": "^1.0" and there are no problems with conflicts. BUT has problem with PHP 8.1

Cannot use 'readonly' as an identifier. It is a reserved keyword since PHP 8.1

in

interface Fillable extends ReadOnly

I'm thinking of an option where even if I migrate twice, I can get a new version...

lindyhopchris commented 2 years ago

@veneliniliev you need to use laravel-json-api/laravel:^2.0 as that works with PHP 8.1 (it fixes that readonly problem).

veneliniliev commented 2 years ago

@veneliniliev you need to use laravel-json-api/laravel:^2.0 as that works with PHP 8.1 (it fixes that readonly problem).

yes, but I return to the first problem. obviously, migration will not be easy :(

lindyhopchris commented 2 years ago

FYI have started working on upgrading cloudcreativity/laravel-json-api to the latest version of the Neomerx dependency, so that both the old and new packages could be installed at once.

It's looking like a big job, so not sure how long it will take me. But have started!

veneliniliev commented 2 years ago

this is good news. if I can help with something... i'm ready :)

lindyhopchris commented 2 years ago

thanks for the offer! it's a bit difficult to split up as I'm really not sure where the problems are without exploring and fixing stuff as I go. So think I'll just keep plugging on with it, probably this coming weekend.

lindyhopchris commented 2 years ago

Latest update on this. I'm 95% of the way through upgrading the neomerx dependency. Basically it's all working (as far as I can tell) except for default include paths. My first attempt at getting them working hasn't worked, so need to try another approach.

Just thought I'd put an update here so you all know I'm still working on this!

veneliniliev commented 2 years ago

I hope you can find a good solution. it would be very convenient to smoothly migrate versions. I have a project with a lot of tests and I will find out if everything works properly

lindyhopchris commented 2 years ago

Good news, just tagged v5.0.0-alpha.1 that has the Neomerx upgrade in it. As I don't have this package in any applications anymore, I really need people to give it a go and let me know if there's anything that isn't working. (If you find something that isn't working, create a new issue and make it clear on the issue you're using the 5.0 alpha version.)

Upgrade guide is here. Also let me know if there's any steps missing from the upgrade guide: https://github.com/cloudcreativity/laravel-json-api/blob/v5.0.0-alpha.1/docs/upgrade.md

veneliniliev commented 2 years ago

all my tests passed! I will test a little more and the installation of the new package. tnx!

veneliniliev commented 2 years ago

@lindyhopchris I have a problem. in the old version, the order of includes was different.

example: includes=relation.subrelation in v4 response: includes:[ subrelation..., relation... ],

in v5 response: includes:[ relation... subrelation..., ]

is there an option for them to come the old way because the frontend library doesn't recognize the relations because it goes through them in order and doesn't find the resources?

lindyhopchris commented 2 years ago

I believe the spec says that there is no significance to the order of the resources in the included top-level member. I'll need to find that in the spec.

The frontend library should be using the type and id combination that forms the resource identifier in the relationship to locate the resources in the included member. Trying to find it by numeric index in the included array seems extremely strange as the order isn't guaranteed.

veneliniliev commented 2 years ago

@lindyhopchris everything looks fine. already works on prod!

lindyhopchris commented 6 months ago

Closing this as this issue is now effectively done.