Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Better way to store/retrieve separate Shop App installs #91

Closed
paulcanning opened this issue Aug 30, 2018 · 9 comments
Closed

Better way to store/retrieve separate Shop App installs #91

paulcanning opened this issue Aug 30, 2018 · 9 comments
Assignees
Labels
feature Enhancement to the code

Comments

@paulcanning
Copy link

Currently, this framework assumes it will be a single app.

In my use-case, my single Laravel app is serving multiple Shopify Apps.

The current way to get Shop info is to look up the shop domain in the shops table, but if multiple apps are logging data into that table, there is no way to differentiate.

I was considering adding an extra column that would be the apps namespace which gets added to all calls to the shop model.

Thoughts? Ideas?

@brianakidd
Copy link

Wow, this sounds brutal. Are the different apps you are serving so similar in functionality that you can manage it within one code base?

Are there reasons why you wouldn't want one project = one app? Hosting costs, maybe?

@paulcanning
Copy link
Author

The apps are split into Laravel Packages. The are being served via a single Laravel application in order to maintain a small app ecosystem. Also, for fun!

@gnikyt
Copy link
Owner

gnikyt commented Aug 30, 2018

Is this something common to do? I've always done one db/setup per app sort of thing. If it something fairly common I don't pursuing it.. I think namespace on the shop table would be the best since thats the main table. If I we're to bake it in, I would probably have a env setting which could define a namespace (app handle or something), and mod the firstOrCreate method on auth to use that namespace, and a scope on the shop model which would add it to every call

@paulcanning
Copy link
Author

I'm using package configs, rather than the global .env file, so that all app configs are separeted.

Yea, the namespace column in the shop table is the likely answer, for now.

Is it common? No idea, as I find it difficult to find anyone actively talking about Shopify app development.

@gnikyt
Copy link
Owner

gnikyt commented Aug 30, 2018

I find it difficult to find anyone actively talking about Shopify app development

Very true.

By .env yes I meant the config PHP file. I don't mind baking this in, if its beneficial to others.

@gnikyt gnikyt self-assigned this Aug 30, 2018
@gnikyt
Copy link
Owner

gnikyt commented Aug 31, 2018

@paulcanning Decided to hack at this, I can see the use-case. PR #92 covers this.

Changes:

  • Added namespace column to shop table (ex)
  • Global scope to Shop model which appends where namespace = ? to all queries (ex)
  • An observer to automatically add namespace to a new shop on create (ex)
  • New config entry to define namespace either via config PHP file for env (ex)

Will be doing more reviewing to ensure all is covered.

@paulcanning
Copy link
Author

FYI - this may be premature, as I'm currently stuck on making binds work with each individual app package.

@gnikyt
Copy link
Owner

gnikyt commented Aug 31, 2018 via email

@gnikyt gnikyt added feature Enhancement to the code status-resolved labels Aug 31, 2018
@gnikyt
Copy link
Owner

gnikyt commented Aug 31, 2018

v3.2.0 release contains the namespace abilities. Doc on setup/usage as well.

Will close for now, unless you wish to continue discussion, thanks!

@gnikyt gnikyt closed this as completed Aug 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Enhancement to the code
Projects
None yet
Development

No branches or pull requests

3 participants