TypeError Argument 1 passed to ShopifyUtils::sanitizeShopDomain() must be of the type string,

I getting below error,

TypeError
Argument 1 passed to ShopifyUtils::sanitizeShopDomain() must be of the type string, null given, called in /var/www/html/shopiapp/test_me/routes/web.php on line 29
http://127.0.0.1:8081/ 

enter image description here

enter image description here

web.php

<?php

use AppModelsSession;
use IlluminateHttpRequest;
use IlluminateHttpResponse;
use IlluminateSupportFacadesLog;
use IlluminateSupportFacadesRoute;
use ShopifyAuthOAuth;
use ShopifyAuthSession as AuthSession;
use ShopifyClientsHttpHeaders;
use ShopifyClientsRest;
use ShopifyContext;
use ShopifyUtils;
use ShopifyWebhooksRegistry;
use ShopifyWebhooksTopics;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::fallback(function (Request $request) {
$shop = Utils::sanitizeShopDomain($request->query('shop')); //this line shows the error...
$host = $request->query('host');
$appInstalled = Session::where('shop', $shop)->exists();
if ($appInstalled) {
return view('react', [
'shop' => $shop,
'host' => $host,
'apiKey' => Context::$API_KEY
]);
}
return redirect("/login?shop=$shop");
});

Route::get('/login/toplevel', function (Request $request, Response $response) {
$shop = Utils::sanitizeShopDomain($request->query('shop'));

$response = new Response(view('top_level', [
'apiKey' => Context::$API_KEY,
'shop' => $shop,
'hostName' => Context::$HOST_NAME,
]));

$response->withCookie(cookie()->forever('shopify_top_level_oauth', '', null, null, true, true, false, 'strict'));

return $response;
});

Route::get('/login', function (Request $request) {
$shop = Utils::sanitizeShopDomain($request->query('shop'));

if (!$request->hasCookie('shopify_top_level_oauth')) {
return redirect("/login/toplevel?shop=$shop");
}

$installUrl = OAuth::begin(
$shop,
'/auth/callback',
true,
['AppLibCookieHandler', 'saveShopifyCookie'],
);

return redirect($installUrl);
});

Route::get('/auth/callback', function (Request $request) {
$session = OAuth::callback(
$request->cookie(),
$request->query(),
['AppLibCookieHandler', 'saveShopifyCookie'],
);

$host = $request->query('host');
$shop = Utils::sanitizeShopDomain($request->query('shop'));

$response = Registry::register('/webhooks', Topics::APP_UNINSTALLED, $shop, $session->getAccessToken());
if ($response->isSuccess()) {
Log::debug("Registered APP_UNINSTALLED webhook for shop $shop");
} else {
Log::error(
"Failed to register APP_UNINSTALLED webhook for shop $shop with response body: " .
print_r($response->getBody(), true)
);
}

return redirect("?" . http_build_query(['host' => $host, 'shop' => $shop]));
});

Route::post('/graphql', function (Request $request) {
$response = Utils::graphqlProxy($request->header(), $request->cookie(), $request->getContent());

$xHeaders = array_filter(
$response->getHeaders(),
function ($key) {
return str_starts_with($key, 'X') || str_starts_with($key, 'x');
},
ARRAY_FILTER_USE_KEY
);

return response($response->getDecodedBody(), $response->getStatusCode())->withHeaders($xHeaders);
})->middleware('shopify.auth:online');

Route::get('/rest-example', function (Request $request) {
/** @var AuthSession */
$session = $request->get('shopifySession'); // Provided by the shopify.auth middleware, guaranteed to be active

$client = new Rest($session->getShop(), $session->getAccessToken());
$result = $client->get('products', [], ['limit' => 5]);

return response($result->getDecodedBody());
})->middleware('shopify.auth:online');

Route::post('/webhooks', function (Request $request) {
try {
$topic = $request->header(HttpHeaders::X_SHOPIFY_TOPIC, '');

$response = Registry::process($request->header(), $request->getContent());
if (!$response->isSuccess()) {
Log::error("Failed to process '$topic' webhook: {$response->getErrorMessage()}");
return response()->json(['message' => "Failed to process '$topic' webhook"], 500);
}
} catch (Exception $e) {
Log::error("Got an exception when handling '$topic' webhook: {$e->getMessage()}");
return response()->json(['message' => "Got an exception when handling '$topic' webhook"], 500);
}
});

Utils.php

<?php

declare(strict_types=1);

namespace Shopify;

use ShopifyContext;
use ShopifyAuthOAuth;
use ShopifyAuthSession;
use ShopifyClientsGraphql;
use ShopifyClientsHttpResponse;
use ShopifyExceptionInvalidArgumentException;
use ShopifyExceptionSessionNotFoundException;
use FirebaseJWTJWT;

/**
* Class to store all util functions
*/
final class Utils
{
/**
* Returns a sanitized Shopify shop domain
*
* If the provided shop domain or hostname is invalid or could not be sanitized, returns null.
*
* @param string $shop A Shopify shop domain or hostname
* @param string|null $myshopifyDomain A custom Shopify domain
*
* @return string|null $name a sanitized Shopify shop domain, null if the provided domain is invalid
*/
public static function sanitizeShopDomain(string $shop, ?string $myshopifyDomain = null): ?string
{
$name = trim(strtolower($shop));

$allowedDomainsRegexp = $myshopifyDomain ? "($myshopifyDomain)" : "(myshopify.com|myshopify.io)";

if (!preg_match($allowedDomainsRegexp, $name) && (strpos($name, ".") === false)) {
$name .= '.' . ($myshopifyDomain ?? 'myshopify.com');
}
$name = preg_replace("/A(https?://)/", '', $name);

if (preg_match("/A[a-zA-Z0-9][a-zA-Z0-9-]*.{$allowedDomainsRegexp}z/", $name)) {
return $name;
} else {
return null;
}
}

/**
* Determines if the request is valid by processing secret key through an HMAC-SHA256 hash function
*
* @param array $params array of parameters parsed from a URL
* @param string $secret the secret key associated with the app in the Partners Dashboard
*
* @return bool true if the generated hex digest is equal to the hmac parameter, false otherwise
*/
public static function validateHmac(array $params, string $secret): bool
{
$hmac = $params['hmac'] ?? '';
unset($params['hmac']);

$computedHmac = hash_hmac('sha256', http_build_query($params), $secret);

return hash_equals($hmac, $computedHmac);
}

/**
* Retrieves the query string arguments from a URL, if any
*
* @param string $url The URL string with query parameters to be extracted
*
* @return array $params Array of key/value pairs representing the query parameters or empty array
*/
public static function getQueryParams(string $url): array
{
$queryString = parse_url($url, PHP_URL_QUERY);
if (empty($queryString)) {
return [];
}
parse_str($queryString, $params);
return $params;
}

/**
* Checks if the current version of the app (from Context::$API_VERSION) is compatible, i.e. more recent, than the
* given reference version.
*
* @param string $referenceVersion The version to check
*
* @return bool
* @throws ShopifyExceptionInvalidArgumentException
*/
public static function isApiVersionCompatible(string $referenceVersion): bool
{
if (Context::$API_VERSION === 'unstable' || Context::$API_VERSION === 'unversioned') {
return true;
}

if (!ctype_digit(str_replace('-', '', $referenceVersion))) {
throw new InvalidArgumentException("Reference version '$referenceVersion' is invalid");
}

$currentNumeric = (int)str_replace('-', '', Context::$API_VERSION);
$referenceNumeric = (int)str_replace('-', '', $referenceVersion);

return $currentNumeric >= $referenceNumeric;
}

/**
* Loads and offline session
* No validation is done on the shop param; ensure it comes from a safe source
*
* @param string $shop The shop URL to find the offline session for
* @param bool $includeExpired Optionally include expired sessions, defaults to false
*
* @return Session|null If exists, the most recent session
* @throws ShopifyExceptionUninitializedContextException
*/
public static function loadOfflineSession(string $shop, bool $includeExpired = false): ?Session
{
Context::throwIfUninitialized();

$sessionId = OAuth::getOfflineSessionId($shop);
$session = Context::$SESSION_STORAGE->loadSession($sessionId);

if ($session && !$includeExpired && !$session->isValid()) {
return null;
}

return $session;
}

/**
* Loads the current user's session based on the given headers and cookies.
*
* @param array $rawHeaders The headers from the HTTP request
* @param array $cookies The cookies from the HTTP request
* @param bool $isOnline Whether to load online or offline sessions
*
* @return Session|null The session or null if the session can't be found
* @throws ShopifyExceptionCookieNotFoundException
* @throws ShopifyExceptionMissingArgumentException
*/
public static function loadCurrentSession(array $rawHeaders, array $cookies, bool $isOnline): ?Session
{
$sessionId = OAuth::getCurrentSessionId($rawHeaders, $cookies, $isOnline);

return Context::$SESSION_STORAGE->loadSession($sessionId);
}

/**
* Decodes the given session token and extracts the session information from it
*
* @param string $jwt A compact JSON web token in the form of XXXX.yyyy.zzzz
*
* @return array The decoded payload which contains claims about the entity
*/
public static function decodeSessionToken(string $jwt): array
{
$payload = JWT::decode($jwt, Context::$API_SECRET_KEY, array('HS256'));
return (array) $payload;
}

/**
* Forwards the GraphQL query in the HTTP request to Shopify, returning the response.
*
* @param array $rawHeaders The headers from the HTTP request
* @param array $cookies The cookies from the HTTP request
* @param string $rawBody The raw HTTP request payload
*
* @return HttpResponse
* @throws PsrHttpClientClientExceptionInterface
* @throws ShopifyExceptionCookieNotFoundException
* @throws ShopifyExceptionMissingArgumentException
* @throws ShopifyExceptionSessionNotFoundException
* @throws ShopifyExceptionUninitializedContextException
*/
public static function graphqlProxy(array $rawHeaders, array $cookies, string $rawBody): HttpResponse
{
$session = self::loadCurrentSession($rawHeaders, $cookies, true);
if (!$session) {
throw new SessionNotFoundException("Could not find session for GraphQL proxy");
}

$client = new Graphql($session->getShop(), $session->getAccessToken());

return $client->proxy($rawBody);
}
}

I have tried to create a public app (PHP), and I get this error.
I’m Uses UBUNTU System,
how can I fix this?

hello developers, please help me with this, I don’t understand that where can I need to change? in the files,
because when I create an app using PHP the code is done by shopify-cli.

there is not any solution to this question?
please help me with this, I’m a beginner at Shopify, so need your bits of help.