Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run luya command on shared hosting via php shell #1856

Closed
Saraylu opened this issue Sep 20, 2018 · 12 comments
Closed

Run luya command on shared hosting via php shell #1856

Saraylu opened this issue Sep 20, 2018 · 12 comments
Assignees
Labels

Comments

@Saraylu
Copy link

Saraylu commented Sep 20, 2018

I use p0wny-shell for executing luya commands 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();
@nadar
Copy link
Contributor

nadar commented Sep 21, 2018

I never used p0wny shell, so i am not sure if or why this encounters this exception. Maybe this emulates a web proccess instead of a cgi process - not sure. What would: php_sapi_name() return inside this p0wny shell? Maybe this wont work in this case: https://github.com/luyadev/luya/blob/master/core/base/Boot.php#L70-L83

@Saraylu
Copy link
Author

Saraylu commented Sep 21, 2018

Notice: 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.


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.

@Saraylu
Copy link
Author

Saraylu commented Sep 21, 2018

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

@nadar
Copy link
Contributor

nadar commented Sep 21, 2018

I agree - i am going to fix this. if console application is requested, the sapi name should be used, this is only used if you want the application to decide by yourself with $boot->run()

@nadar nadar added bug and removed bug:research labels Sep 21, 2018
@nadar nadar self-assigned this Sep 21, 2018
nadar added a commit that referenced this issue Sep 21, 2018
@nadar
Copy link
Contributor

nadar commented Sep 21, 2018

try to install dev-master of luya core and check if it works now.

@Saraylu
Copy link
Author

Saraylu commented Sep 22, 2018

After updating only luya-core to dev-master on localhost, I replaced vendor/luyadev/luya-core directory from localhost to shared hosting.

Result: Error: Unable to determine the entry script file path. without any error_log

p0wny@shell:…/public_html/web# ../vendor/bin/luya

This is Yii version 2.0.15.1.

The following commands are available:

- asset                        Allows you to combine and compress your JavaScript and CSS files.
    asset/compress (default)   Combines and compresses the asset files according to the given configuration.
    asset/template             Creates template of configuration file for [[actionCompress]].

- cache                        Allows you to flush cache.
    cache/flush                Flushes given cache components.
    cache/flush-all            Flushes all caches registered in the system.
    cache/flush-schema         Clears DB schema cache for a given connection component.
    cache/index (default)      Lists the caches that can be flushed.

- fixture                      Manages fixture data loading and unloading.
    fixture/load (default)     Loads the specified fixture data.
    fixture/unload             Unloads the specified fixtures.

- health                       Health/Status informations about the Application itself.
    health/index (default)     Create all required directories an check whether they are writeable or not.
    health/mailer              Test Mail-Component (Use --verbose=1 to enable smtp debug output)

- help                         Provides help information about console commands.
    help/index (default)       Displays available commands or the detailed information
    help/list                  List all available controllers and actions in machine readable format.
    help/list-action-options   List all available options for the $action in machine readable format.
    help/usage                 Displays usage information for $action.

- import                       Import controller runs the module defined importer classes.
    import/index (default)     Run the import process.

- message                      Extracts messages to be translated from source files.
    message/config             Creates a configuration file for the "extract" command using command line options specified.
    message/config-template    Creates a configuration file template for the "extract" command.
    message/extract (default)  Extracts messages to be translated from source code.

- migrate                      Database Migration Too.
    migrate/create             @inheritDoc
    migrate/down               Downgrades the application by reverting old migrations.
    migrate/fresh              Truncates the whole database and starts the migration from the beginning.
    migrate/history            Displays the migration history.
    migrate/mark               Modifies the migration history to the specified version.
    migrate/new                Displays the un-applied new migrations.
    migrate/redo               Redoes the last few migrations.
    migrate/to                 Upgrades or downgrades till the specified version.
    migrate/up (default)       Upgrades the application by applying new migrations.

- module                       Command to create a new LUYA Module.
    module/create (default)    Create a new frontend/admin module.

- serve                        Runs PHP built-in web server.
    serve/index (default)      Runs PHP built-in web server.

Status: 500 Internal Server Error
X-Powered-By: PHP/7.2.10
Content-type: text/html; charset=UTF-8

Error: Unable to determine the entry script file path.

But when I changed line 20 of vendor/luyadev/luya-core/bin/luya
from $boot->configFile = 'configs/env.php';
to $boot->configFile = __DIR__ . '/../../../../configs/env.php';
Result was:

p0wny@shell:…/public_html/web# ../vendor/bin/luya
Status: 500 Internal Server Error
X-Powered-By: PHP/7.2.10
Content-type: text/html; charset=UTF-8

and this error appeared in vendor/luyadev/luya-core/bin/luya/error_log file:

[21-Sep-2018 23:25:42 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(179): require('/home/x/...')
#5 /home/x/public_html/vendor/luyadev/luya-core/base/Boot.php(219): luya\base\Boot->getConfigArray()
#6 /home/x/public_html/vendor/luyadev/luya-core/bin/luya(25): luya\base\Boot->applicationConsole()
#7 {main}
  thrown in /home/x/public_html/vendor/yiisoft/yii2/web/Request.php on line 850

@Saraylu
Copy link
Author

Saraylu commented Sep 22, 2018

Notice that i use p0wny-shell on localhost and work with any issue.
I guess the problem is from the Shared Hosting side

@Saraylu
Copy link
Author

Saraylu commented Sep 22, 2018

Notice: https://stackoverflow.com/questions/28339509/yii2-unable-to-determine-the-entry-script-file-path-change-php-server-environ


Edit:
I'm almost sure that the problem is the Server API(SAPI). On my shared host php_sapi_name() return cgi-fcgi while we need cli. I'm now consulting with Shared Hosting Provider.

Thanks for your efforts

@nadar
Copy link
Contributor

nadar commented Sep 22, 2018

thanks for investigating. The p0wny shell will never run in cli mode, as its running trough the webserver. What does your config look like?

#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/...')

The stack trace looks like it would open web request in env-local.php

@Saraylu
Copy link
Author

Saraylu commented Sep 22, 2018

Solved

yes, the issue was related to SAPI that the p0wny shell works in Fast/CGI mode. On almost Shared Hosting cli SAPI is not available. the only way to run LUYA command line tools is using Cron Jobs that will work in cli mode.

Cron Job example:
/usr/local/bin/php /home/x/public_html/vendor/luyadev/luya-core/bin/luya

Very thanks @nadar & all friends to help me :)

@nadar
Copy link
Contributor

nadar commented Sep 24, 2018

But in the last commit, LUYA where not switching config based on SAPI name. So maybe i am gonig to try it as well. Bit if your issue is solved, we can close?

@Saraylu
Copy link
Author

Saraylu commented Sep 24, 2018

But in the last commit, LUYA where not switching config based on SAPI name.

before last commit and after it, my mistake was in debugging, that i changed config path file in vendor/luyadev/luya-core/bin/luya witch caused a the web request:
from $boot->configFile = 'configs/env.php';
to $boot->configFile = __DIR__ . '/../../../../configs/env.php';

However I think it's better that when LUYA Command Tool called as a web request, suitable message throw out to end-user like "LUYA Command Tool only works in CLI SAPI"

@nadar my issue was solved, can close it. thanks for help :)

@nadar nadar closed this as completed Sep 24, 2018
nadar added a commit that referenced this issue Aug 27, 2019
nadar added a commit that referenced this issue Aug 27, 2019
* Update app-admin-module-assets.md

* ResponseCache using PageCache filter and mark $actionsCallable and
$actions as deprecated. #1827

* Update app-cmsproperties.md (#1828)

* Update app-cmsproperties.md

move comment

* Update app-cmsproperties.md

* Update app-cmsproperties.md

* Update app-admin-module.md (#1829)

* Add files via upload

* Update app-language.md

* Lazyload widget asset registration issue fixed when used in nested
context. closes #1830

* Create ngrest-api.md

* Update README.md

* Update ngrest-api.md

* Update ngrest-api.md

* Fixed issue with create url and complex composition patterns. #1831

* Update ngrest-api.md

* Update ngrest-api.md

* fix php doc

* add option for apiRules
luyadev/luya-module-admin#174

* Update app-translation.md

* Update app-translation.md

* Translation to English

* Update organisation.md

* Update organisation.md

* Update organisation.md

* Corrections. (#1836)

* Corrections.

* Update organisation.md

* Update organisation.md

* Update organisation.md

* make web bootstrap bc safe

* Update luya-package-dev.md

* Added new option `Composer::$hideDefaultPrefixOnly`  (#1834)

* Add `hideDefaultPrefixOnly` option

When enabled, composition prefixes will be hidden only for default language. Takes effect only when `hidden` option is disabled.

* Add Changelog record for `Composer::$hideDefaultPrefixOnly`

* Update app-translation.md

* Update app-translation.md

* Add `hideDefaultPrefixOnly` option

When enabled, composition prefixes will be hidden only for default language. Takes effect only when `hidden` option is disabled.

* Add Changelog record for `Composer::$hideDefaultPrefixOnly`

* add unit test

* Update CHANGELOG.md

* prepare release

* release bump

* remove comment

* api and headless update

* changed docs for new ActiveWindowFromWidget
luyadev/luya-module-admin#188

* Add body params to error report

* fix issue where only admin module is available and set as default route

* Update UPGRADE.md (#1839)

* auto convert mail message to alt body closes #1840

* Polish translation (#1841)

* Issue 1816 (#1843)

* View mapping for module action

* Unit Test for viewmapping

* Viewmap refactoring

* Viewpath refactoring

* Bugfix

* Changelog

* PHPdoc

* Translation Helper for dev (#1844)

* Translation helper controler

* PHPdoc

* PHPdoc

* Reformat

* Changelog #1844

* closes luyadev/luya-module-admin#185

* Fix issue where frontend rules have precedence over admin closes #1848

* cs fix and remove random aded char.

* prepare for release

* release bump

* add new truncate middle helper

* closes #1850, closes #1851

* Updated svg widget to enable svg > use implementation for svg sprites (#1852)

* Updated svg widget to enable svg > use implementation for svg sprites
* Added changelog entry; Added @SInCE tags

* add callable option for mock arguments closes #1853

* force cli env when applicationConsole is called #1856

* yii base object not available #1856

* Update organisation.md (#1858)

* Update app-module-urlrules.md

* Update app-module-urlrules.md

* Update app-module-urlrules.md

* docs and typos (closes #1812)

* update menu

* prepare for release

* bump release

* lock file update

* Update app-module-urlrules.md

* Update concept-depandsync.md (#1860)

* Update app-storage.md

* Update app-storage.md

* Update app-menu.md

* Update install-structures.md

* github markdown fixer

* Issue 1855 (#1861)

* Translation helper controler

* PHPdoc

* Unique url in Modul-Block context #1855

* Updated luya guideline GULP and CSS infos

* Updated Resources section

* Update luya-guideline.md

* Update app-module-urlrules.md

* Update app-module-urlrules.md

* fixed alt body cleanup closes #1859

* fixed alias use in renderLayout closes #1863

* Example for custom directives (#1865)

closes #1864

* Make ./luya serve command work out of the box (#1866)

Before:

```
$ ./luya serve
Document root "/home/cebe/dev/cebe.cc/luya/web" does not exist.
```

After:

```
$ ./luya serve
Server started on http://localhost:8080/
Document root is "/home/cebe/dev/cebe.cc/luya/public_html"
Quit the server with CTRL-C or COMMAND-C.

```

* add changelog #1866

* Update luya-package-dev.md

* Fix bug with word highlight in string helper. closes #1869

* prepare for release

* release bump

* Update luya-guideline.md

* string helper highlight word accepts list of words closes #1872

* string helper truncate middle no results output and strict compare closes #1870

* remove word highlight case sensitivity #1871

* Lazyload widget update (#1868)

* Initial update for base64 encode; Needs more work; #1867
* Updated widget
* Rewritten lazyload js and added new placeholderSrc. Updated lazyload docs; #1867
* Updated widget and documentation for better base64 usability; Added @SInCE tags; #1867
* Updated styles for placeholder div
* Fixed an issue that occurs if two types of lazyloading are used on one page
* Added package.json; Added Karma conf; Added first basic LazyLoad tests
* Update LazyLoad.php

* Updated LazyLoading to improve placeholder behaviour; Updated tests

* Fixed small issue with placeholder height

* Added LocalBusiness Json-Ld. Fixed Event Json-Ld, and TypeHinting. #1872

* add new schema org entries #1872

* remove empty values by default

* add new guide section for active buttons

* fix local business inheritance, rating, aggregate rating and postal address. #1872

* fix range issue

* Update app-storage.md

* use debug message isntead of info

* Extend guide "Admin permission" (#1873)

* Update app-storage.md (#1874)

*  Correct parameter order for help (#1875)

* Translation helper controler

* PHPdoc

* Correct parameter order for help

* Update RepoController.php

* change empty/null value handling

* update curl version constraint

* prepare for release

* bump version

* Update app-blocks.md

* Create app-admin-module-api.md

* Update README.md

* Update app-admin-module-api.md (#1880)

* Update app-admin-module-api.md

* Update app-admin-module-api.md

* Update app-admin-module-api.md

* Update app-admin-module-api.md

* Quote highlight word

* Update RangeValue.php

* Add requires.push info

liberosoft/luyawysiwyg#1

* Url module controller context fix (#1877)

* Translation helper controler

* PHPdoc

* Correct parameter order for help

* Bugfix with language switcher #1876

* Unit test fix

* Refactoring urlReplaceModule

* Changelog

* Typo

* Documentation for block preview  (#1884)

* Documentation for block preview luyadev/luya-module-cms#83

* Documentation for block preview luyadev/luya-module-cms#83

* change naming

* Update app-admin-module-dashboardobjects.md

* Update app-admin-module-dashboardobjects.md

* Updated lazyload: Added function refetchElements to force lazyload to handle new images (for example in async loaded content)

* LazyLoading: Small fix to prevent issues with adding new images to existing page

* LazyLoad: Fixed small issue with id/index

* closes #1888 closes #1887

* Changelog update; Closes #1889

* Fixed issue with lazyloading; #1889

* Fix issue where current url rule appends path param. closes #1885

* add originalArgs for request route

* add php 7.3

* allow php 7.3 to fail

* Correct a typing error (#1893)

* add email tag obfuscation #1895

* change unit tests, encoding ensure mailto

* fix html class name

* fix email tag obfuscation

* ensure obfuscation encoding #1895

* Update concept-depandsync.md

* PHPDoc correction (#1896)

Corrected class (changed from old deprecated to new Behavior)

* fix issue with yii constants closes #1897

* fix telephone link exception closes #1898

* Update Formatter.php (#1899)

Typo

* Fix Composition::createRouteEnsure (#1902)

* Fix Composition::createRouteEnsure

with hideDefaultPrefixOnly == true composition component should not hide lang code if current lang *is* default but the url being constructed *is not* (e.g. LanguageSwitcher)

* CHANGELOG entry

* fixed variable declaration and psr isset

* revert Yii include hirarchy #1897

* use basename for mail attachment closes #1900

* Update app-blocks.md

* refactor resolver #1905

* add $expectedValues for valid language testing #1905

* add not found catch in url manager #1905

* add active window buttons to doc

* Update install-upgrade.md

* Issue 1907 (#1908)

* add test case and new regex #1907

* add tag sub value escapeing #1907

* add changelog #1907

* Update TagParser.php

* prepare for release

* release bump

* Delete ISSUE_TEMPLATE.md

* Delete PULL_REQUEST_TEMPLATE.md

* Update luya-collaboration.md

* Fix StringHelper::highlightWord delimiter issue closes #1909

* Fixed resized callback in lazyload js; Closes #1910

* Update organisation.md

* Fixed bug in ArrayHelper::searchColumn() when using assoc arrays. closes #1911

* prepare for release

* prepare packages for semver

* use parent unlink class for file helper

* update git wrapper dependencies

* add new trait helper #1912

* fix regex issue with php 7.3

* add php 7.3

* add deprecated info

* fix robots filter session problem #1914

* change constraint

* remove fixed platform

* ignore platform requirements

* move to require dev

* use version 1 of git wrapper package

* fix robot filter bug

* ignore platform reqs

* add platform

* add robot tests

* merge variables

* change min requirement

* update lock file

* Update ngrest-plugins.md (#1915)

There is an mystype in renderList method

* change loader path finder

* use relative path for config in bin closes #1799

* Update luya-guideline.md

* Update ngrest-activewindow.md

* Update app-admin-module-assets.md

* Update app-admin-module-assets.md

* prepare for release

* add changelog section

* release bump

* Update install-upgrade.md

* Formating inproved (#1919)

* add resolveHostInfo #1921

* admin 2.0 draft

* Update note_admin-2.0.0.md

* Update note_admin-2.0.0.md

* use new ds seperator

* pools guide luyadev/luya-module-admin#236

* add images for admin 2.0 release note

* change image paths

* text updates

* Update note_admin-2.0.0.md (#1922)

* fixed issue with binary

* add notifications text draft

* update news

* prepare for release

* update lock file

* update changelog

* release bump

* allow git wrapper version 1

* Update install-upgrade.md

* add new object helpers #1925

* use static functions

* fix bug in fileToName method

* add new console command context check #1927

* use fix class path #1927

* Update luya-package-dev.md

* use code climate

* fixed issue with relativ links in link tag #1931

* add travis unit test verbosity

* ensure object helper method does not throw exceptio

* add invalid param exception to try catch block

* prepare for release

* release bump

* Update app-storage.md

* Update deploy file with best practises and example (#1934)

* Update deploy file with best practises and example

* Update concept-depandsync.md

* Update concept-depandsync.md

* add rest helper

* Update text on page properties (#1935)

* Update text on page properties

Some typo's, explanation on where to find these properties in the CMS part and code on how to use the properties in a view.

* Update app-cmsproperties.md

* Travis mysql connection failed (#1937)

* Translation helper controler

* PHPdoc

* Correct parameter order for help

* Documentation for block preview luyadev/luya-module-cms#83

* Revert PHP doc

* Travis mysql connection failed

* fix rest helper with static key word

* fix use statement

* add cleanHost and domain methods closes #1940

* add infos to error handler #1939

* filter empty array values

* check if file is empty

* add changelog closes #1941

* add subdomain test

* add php doc

* prepare changelog

* add test

* use setFrom() #1942

* version bump

* allow to extend composite auth methods

* Update install-problems.md

* add optional auth actions to rest behavior

* Update CHANGELOG.md

* Update ngrest-plugin-select.md

* Update ngrest-plugin-select.md

* Update ngrest-plugin-select.md

* Update ngrest-plugin-select.md

* Update ngrest-plugin-select.md

* add bootstrap, add changelog, add docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants