-
-
Notifications
You must be signed in to change notification settings - Fork 374
Upgrading
Please refer to the Changelog doc as well..
Caution: This may or may not be a complete idea of the upgrade path required.
- Copy all new internal view files
- Replace all routes with
auth.shopify
middleware toverify.shopify
- Replace all routes with
auth.token
middleware toverify.shopify
- Remove all reference to routes with
itp
middleware - Run
php artisan vendor:publish --tags=migrations
, and runphp artisan migrate
to run the new migration forusers
to add password time field - Open
\App\Http\Middleware\VerifyCsrfToken.php
and add:
protected $except = [
'*',
];
to disable all CSRF. There is no workaround for this at the moment.
7. If using SPA, you can take advantage of window.sessionToken
for the latest token to use with requests
8. If using non-SPA, you can take advantage of using tokenRoute
or tokenRedirect
for your URLs, additionally, anything with class .session-token
will have the latest token to use with requests
See wiki for more information on tokens.
ITP:
Any custom web routes you have defined, it is a good idea to append the new itp
middleware. Example:
Route::get('/tag-test', 'TagTestController@handle')
->middleware(['auth.shopify'])
->name('tag-test');
Would become:
Route::get('/tag-test', 'TagTestController@handle')
->middleware(['itp', 'auth.shopify'])
->name('tag-test');
Config:
ConfigAccessible
trait, and ConfigHelper
service have been removed. The main config function has moved to a global helper getShopifyConfig
.
If you're using either the trait or service in your own code, simply remove it from the files, and instead include:
use function Osiset\ShopifyApp\getShopifyConfig;
And update any $this->getConfig
to getShopifyConfig
.
Similarly, in your Blade files you can reference this new function as well:
{{ \Osiset\ShopifyApp\getShopifyConfig('app_name') }}
All jobs have changed, including webhook jobs. Serializing job constructors with objects (such as ShopDomain, various classes) causes an error, so all jobs now use basic scalar values.
Example: AppUninstalledJob.php
was:
public function __construct(ShopDomain $domain, stdClass $data)
{
$this->domain = $domain;
// ...
}
public function handle(
IShopCommand $shopCommand,
IShopQuery $shopQuery,
CancelCurrentPlan $cancelCurrentPlanAction
): bool {
// ...
}
and is now:
public function __construct(string $domain, stdClass $data)
{
$this->domain = $domain;
// ...
}
public function handle(
IShopCommand $shopCommand,
IShopQuery $shopQuery,
CancelCurrentPlan $cancelCurrentPlanAction
): bool {
// Convert the domain
$this->domain = ShopDomain::fromNative($this->domain);
// ...
}
You will need to convert your existing jobs to use scalar values in the contructor, including AppUninstalledJob
if you have overloaded that job class.
No changes required.
No changes should be required. However, be aware, the login route and view are no longer available. Instead, an exception will be thrown (MissingShopDomainException
) if someone accesses your app directly outside of Shopify.
You may view Custom Exception Handling on how to handle any package exception to your own requirements.
Removal in config/shopify-app.php The following config options were removed:
api_rate_limit_cycle_buffer
api_rate_limit_cycle
api_rate_limiting_enabled
-
api_class
.
Addition in config/shopify-app.php
The following config options we're added, see config/shopify-app.php
in this repo:
api_time_store
api_limit_store
api_deferrer
api_init
Change for API access
The responses from GraphQL and REST calls now return an array
, where previously it was stdClass
.
The body
also returns instance of Osiset\BasicShopifyAPI\ResponseAccess
, which allows you to access the data by object notation or array.
Upgrading is simple, anything where you have $response->body->....
, change to $response['body']->...
or even to $response['body'][...]
.
Example, before:
$response = $shop->api()->rest('GET', '/admin/shop.json');
echo $response->body->shop->name;
Example, after:
$response = $shop->api()->rest('GET', '/admin/shop.json');
echo $response['body']->shop->name; // or $response['body']['shop']['name'];
While the package has been completely rewritten for v11, it may be possible (untested) to upgrade.
https://github.com/osiset/laravel-shopify/wiki/Upgrade-guide-v10.x-to--v11.x
First, follow the installation guide again as shops have moved into native Laravel users.
After this, you would need to match the new database schema for tables like plans
, charges
, etc, as well as apply the new column entries for users
.
Once done, a SELECT INSERT statement to move data from shops into users with their respective columns, keeping the IDs the same will be smoother.
Next, SELECT UPDATE all rows in charges
and plans
table to move the IDs from shop_id
to user_id
.
Next, all casing for status
and type
on charges
table will need to be converted to uppercase.
Next, all casing for type
on plans
table will need to be converted to uppercase.
Next, you would need to update any use statements to the new namespacings.
Next, any webhook jobs would need to accept ShopDomain
as the first argument, not string
, and to get the domain as a string, you would need to use ->toNative()
.
... more to come ...
No internal changes are required. However, be aware partial flow for auth was removed and only full flow auth exists now.
No internal changes are required.
ESDK is now moved to AppBridge. You'll need to update config/shopify-app.php
.
Change
/*
|--------------------------------------------------------------------------
| ESDK Mode
|--------------------------------------------------------------------------
|
| ESDK (embedded apps) are enabled by default. Set to false to use legacy
| mode and host the app inside your own container.
|
*/
'esdk_enabled' => (bool) env('SHOPIFY_ESDK_ENABLED', true),
To:
/*
|--------------------------------------------------------------------------
| AppBridge Mode
|--------------------------------------------------------------------------
|
| AppBridge (embedded apps) are enabled by default. Set to false to use legacy
| mode and host the app inside your own container.
|
*/
'appbridge_enabled' => (bool) env('SHOPIFY_APPBRIDGE_ENABLED', true),
As well, you'll need to migrate your internal views to use AppBridge. The default layout provided by this package (views/layouts/default.blade.php) pulls AppBridge in via CDN; however, you're welcome to override this and use Shopify's NPM package. Toast messages are also migrated.
Two new config values are required in config/shopify-app.php
:
/*
|--------------------------------------------------------------------------
| Shopify API Version
|--------------------------------------------------------------------------
|
| This option is for the app's API version string.
| Use "YYYY-MM" or "unstable". Refer to Shopify's documentation
| on API versioning for the current stable version.
|
*/
'api_version' => env('SHOPIFY_API_VERSION', null),
/*
|--------------------------------------------------------------------------
| Shopify API Grant Mode
|--------------------------------------------------------------------------
|
| This option is for the grant mode when authenticating.
| Default is "offline", "per-user" is available as well.
| Note: Install will always be in offline mode.
|
*/
'api_grant_mode' => env('SHOPIFY_API_GRANT_MODE', 'offline'),
Follow optional guide for 5.2.x => 5.3.0
if applicable.
This release introduces a new major version bump to the underlying Shopify API library, Basic-Shopify-API. This package was bumped as well in case some of you are are handling errors with API calls through try/catch. The difference is, the underlying package now internally catches 4XX-500 errors for you and provides the error and messaging in the response object, so your catch block will not fire for these issues.
For issue #177, this adds the ability to specify a queue name each job should go to (webhooks, scripttags, and after_authenticate).
By default, you do not need to do anything to upgrade, Laravel will fallback to the default queue if no name is given.
However, if you wish to specify, you can re-publish the config for this package or manually modify your config/shopify-app.php
to add the following:
'job_queues' => [
'webhooks' => env('WEBHOOKS_JOB_QUEUE', null),
'scripttags' => env('SCRIPTTAGS_JOB_QUEUE', null),
'after_authenticate' => env('AFTER_AUTHENTICATE_JOB_QUEUE', null),
],
If you have not extended the package in anyway, you should be fine. Else, please see Changelog, upgrade your code and test to ensure it works. This is a major version release.
Three new entries for config/shopify-app.php
, you can use artisan to vendor:publish the config or add the new entries:
'api_rate_limiting_enabled' => env('SHOPIFY_API_RATE_LIMITING_ENABLED', false),
'api_rate_limit_cycle' => env('SHOPIFY_API_RATE_LIMIT_CYCLE', null),
'api_rate_limit_cycle_buffer' => env('SHOPIFY_API_RATE_LIMIT_CYCLE_BUFFER', null),
Breaking changes. Can not guarentee full workability.
- Run the migrations, which will:
- Add
plan_id
toshops
table - Add
freemium
toshops
table - Add
plan_id
tocharges
table - Create a
plans
table
- Add
php artisan vendor:publish --tag=migrations
and php artisan migrate
-
Remove all billing environment values from your env file or
config/shopify-app.php
execept for:billing_enabled
billing_redirect
-
Add to
config/shopify-app.php
:-
billing_freemium_enabled
withtrue
orfalse
-
-
Create a plan or migrate the existing one in your old config, to the database, with
on_install
set totrue
, see [wiki entry|Creating-a-Billable-App#creating-plans] for exact information -
Set all shops'
plan_id
in the database to the ID of the plan created in step 4
- Run the migrations to change the
shops
table and addnamespace
column:
php artisan vendor:publish --tag=migrations
and php artisan migrate
-
Remove the facade entry for this package in
config/app.php
under the facades array (now handled by auto-discovery). -
Remove the provider entry for this package in
config/app.php
under the providers array (now handled by auto-discovery). -
Run the migrations to change the
charges
table'scharge_id
column fromint
tobigint
via:
php artisan vendor:publish --tag=migrations
and php artisan migrate
Breaking changes.
- Run migrations which will remove
charge_id
from the Shop table and create acharges
table:
php artisan vendor:publish --tag=migrations
and php artisan migrate
- Review the installation guide of the wiki (theres a new section on enabling an optional app/uninstalled webhook job).
That's it. There's currently no script to convert the old charge_id
into the charges table for the shops. You can view our wiki on creating a charge under the billing section and manually write a migration script in the meantime.
No internal code upgrades are required.
Simply upgrade the version in your composer file.
To enable billing feature on existing installs of this package:
Open app/Http/Kernel.php
find routeMiddleware
array. Add a new line with:
'billable' => \OhMyBrew\ShopifyApp\Middleware\Billable::class,
Just under auth.shop
, auth.proxy
, auth.webhook
, etc.
road map
Welcome to the wiki!
Please see the homepage for a list of relevant pages.