Run luya command on shared hosting via php shell

Github

I use p0wny-shell for executing LUYA command line tool lik luya import & . . . in Shared Hosting.

Received error:
Uncaught yii\base\InvalidConfigException: Unable to determine the entry script file path. in /home/x/public_html/vendor/yiisoft/yii2/web/Request.php

[20-Sep-2018 23:00:56 UTC] PHP Fatal error:  Uncaught yii\base\InvalidConfigException: Unable to determine the entry script file path. in /home/x/public_html/vendor/yiisoft/yii2/web/Request.php:850
Stack trace:
#0 /home/x/public_html/vendor/yiisoft/yii2/web/Request.php(801): yii\web\Request->getScriptFile()
#1 /home/x/public_html/vendor/yiisoft/yii2/web/Request.php(773): yii\web\Request->getScriptUrl()
#2 /home/x/public_html/configs/env-local.php(17): yii\web\Request->getBaseUrl()
#3 /home/x/public_html/configs/env.php(8): require('/home/x/...')
#4 /home/x/public_html/vendor/luyadev/luya-core/base/Boot.php(136): require('/home/x/...')
#5 /home/x/public_html/vendor/luyadev/luya-core/base/Boot.php(175): luya\base\Boot->getConfigArray()
#6 /home/x/public_html/vendor/luyadev/luya-core/bin/luya(35): luya\base\Boot->applicationConsole()
#7 {main}
  thrown in /home/x/public_html/vendor/yiisoft/yii2/web/Request.php on line 850

luya-core/bin/luya:

#!/usr/bin/env php
<?php

// loaders array
$loaders = [
	'vendor/autoload.php',
	__DIR__ . '/../vendor/autoload.php',
	__DIR__ . '/../../vendor/autoload.php',
	__DIR__ . '/../../../autoload.php',
];

// find vendor if exists
foreach ($loaders as $file) {
	if (file_exists($file)) {
		require($file);
		$vendor = pathinfo($file, PATHINFO_DIRNAME);
	}
}

$boot = new \luya\Boot();
//$boot->configFile = 'configs/env.php';
$boot->configFile = __DIR__.'/../../../../configs/env.php';

$boot->setBaseYiiFile($vendor . '/yiisoft/yii2/Yii.php');
$boot->applicationConsole();

Is possible use Luya command line tool in sharing host?

why is there a Yii web request in a console application?

2 Likes

I think it related to LUYA
don’t know, i only edit this line: $boot-&gt;configFile = __DIR__.'/../../../../configs/env.php'; because the default config file path was not found.

It looks like luya is using the same config for web and console. This is wrong, and should probably be reported as a bug to luya.

To work around the issue you could configure the request component properties scriptUrl and scriptFile.

2 Likes

I set the scriptUrl and scriptFile but was not effective.
However, the same method works on local machine nicely! but on shared hosting the issue exits!!!

It seems that p0wny-shell php_sapi_name returns cgi-fcgi, which means LUYA determines it as a web request (https://github.com/luyadev/luya/blob/master/core/base/Boot.php#L70-L83)

2 Likes

These results obtained through p0wny shell

var_dump(php_sapi_name()); Result: string(8) "cgi-fcgi"

php -v Result:

PHP 7.2.10 (cgi-fcgi) (built: Sep 14 2018 02:50:38)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.4, Copyright (c) 2002-2018, by ionCube Ltd.
    with SourceGuardian v11.2, Copyright (c) 2000-2018, by SourceGuardian Ltd.

Also already I have been debugged the boot.php code and in line 136 the error occurs .

Thanks for the report, we will fix this. Thanks @CeBe for helping

2 Likes

Solved