luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
811 stars 205 forks source link

The console controller can only run within a console Application context. #2073

Closed mhunesi closed 1 year ago

mhunesi commented 3 years ago

What steps will reproduce the problem?

I have two controllers;

  1. commands/SettingsController --->
  2. controllers/SettingsController ---> This Custom Controller.

What is the expected result?

The console controller can only run within a console Application context.

What do you get instead? (A Screenshot can help us a lot!)

image

image

LUYA Check ouput (run this script and post the result: luyacheck.php)

This not working on nginx.

Additional infos

Q A
LUYA Version 1.0.24
PHP Version 7.4
Platform Nginx
Operating system OSX
nadar commented 3 years ago

I dont understand what command you try to execute? Anyhow desired in LUYA is to use the commands folder. What should the other Controller do? What class do you extend from?

mhunesi commented 3 years ago

When I execute controllers/SettingsController Link: http://localhost/en/admin#!/default/5/mymoduleadmin/settings/index

mymoduleadmin has controllers/SettingsController and commands/SettingsController

controllers/SettingsController

namespace app\modules\mymodule\admin\controllers;

class SettingsController extends luya\admin\base\Controller {
    public function actionIndex()
        {
            return $this->render('index', [
                'data' => [], // Data to assign into the view file `index`.
            ]);
        }
}

commands/SettingsController

namespace app\modules\mymodule\admin\commands;

class SettingsController extends \luya\console\Command {
  public function actionIndex()
    {
        return $this->outputSuccess('Action successfully done');
    }
}

Thanks.

nadar commented 3 years ago

So to understand that correctly: You are trying to access the class SettingsController extends luya\admin\base\Controller with mymoduleadmin/settings/index but it seems to run the SettingsController extends \luya\console\Command which of course throws the exception from above? Is that the problem?

bee1194 commented 3 years ago

So i can not use tablePrefix in database. Can you check it?. in file \luyadev\luya-module-admin\src\models\UserGroup.php, line 29 should use{{%admin_user_group}} instead of admin_user_group Thank you

nadar commented 3 years ago

Hi @bee1194 i don't think this has something to do with the topic, but yes you are right. We should fix that. could you send me a PR or create an issue? Thanks

mhunesi commented 3 years ago

So to understand that correctly: You are trying to access the class SettingsController extends luya\admin\base\Controller with mymoduleadmin/settings/index but it seems to run the SettingsController extends \luya\console\Command which of course throws the exception from above? Is that the problem?

Yes. luya-core/console/Controller.php class throws the exception.

nadar commented 3 years ago

@mhunesi so the web request http://localhost/en/admin#!/default/5/mymoduleadmin/settings/index runs the console command? is that your problem? sorry for the delay

nadar commented 1 year ago

I am going to close this issue because:

If you think this is still important or there are more/new informations. Please reopen the issue and let us know.

If this is a problem or a feature you like to discuss, join our discussion: LUYA discussions. We try to keep our issue tracker as clean as possible in order to focus on active issues.