Skip to content

Manual Setup

Sahil Parmar edited this page Mar 14, 2023 · 1 revision

Steps For manual setup.

1. Install Composer pacakage.

composer require kyon147/laravel-shopify

Providers & FacadesProviders & Facades

With Laravel's auto-discover feature, this is handled for you on install.

php artisan vendor:publish --tag=shopify-config

2. Change user model with below code.

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Osiset\ShopifyApp\Contracts\ShopModel as IShopModel;
use Osiset\ShopifyApp\Traits\ShopModel;

class User extends Authenticatable implements IShopModel
{
    use Notifiable;
    use ShopModel;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

3. Migrate tables of the App.

php artisan migrate

4. Setup routes in the web.php.

Route::get('/login', [AuthController::class, 'login'])->name('login');

// Please keep this route snippet last
Route::controller(AuthController::class)->group(function (Router $router) {
    $router->get('/', 'index')->middleware('verify.shopify')->name('home');
    $router->get('/{any}', 'index')->middleware('verify.shopify')->where('any', '(.+)?');
});

NOTE: Please make sure to make your view files as they are in the repo. (You can edit them but they must be present in their respective folders)

5. CSRF middleware disable.

You must disable CSRF as there is currently no solution for verifying session tokens with CSRF, there is a conflict due to new login creation each request.

Open \App\Http\Middleware\VerifyCsrfToken.php, and add or edit:

protected $except = [
    '*',
];

After these steps, You will be able to scaffold basic shopify app. Follow below instructions for more things.