phpMv / ubiquity

Ubiquity framework
https://ubiquity.kobject.net
Apache License 2.0
693 stars 60 forks source link

[scaffolding][Auth]Fatal error: Uncaught Error: Class 'controllers\DAO' not found in C:\...\app\controllers\BaseAuthController.php:24 Stack trace: #0 #52

Closed AyoubTorabi closed 5 years ago

AyoubTorabi commented 5 years ago

Hello ,I encountered the following problem when i test scafolding->Auth https://micro-framework.readthedocs.io/en/latest/scaffolding/auth.html

Fatal error: Uncaught Error: Class 'controllers\DAO' not found in C:...\app\controllers\BaseAuthController.php:24 Stack trace: #0

MyBaseAuthController.php <?php namespace controllers; use Ubiquity\utils\http\USession; use Ubiquity\utils\http\URequest; /**

Admin.php <?php namespace controllers; use Ubiquity\controllers\admin\UbiquityMyAdminBaseController; use Ubiquity\controllers\auth\WithAuthTrait;

class Admin extends UbiquityMyAdminBaseController{ // Error with use WithAuthTrait; protected function getAuthController(): AuthController { return new BaseAuthController(); } }

jcheron commented 5 years ago

Hi, all imports (uses) are not mentionned in doc. You must add in your BaseAUthController class: use Ubiquity\orm\DAO;

AyoubTorabi commented 5 years ago

Error Message : Declaration of controllers\BaseAuthController::_isValidUser() must be compatible with Ubiquity\controllers\auth\AuthController::_isValidUser($action = NULL)

AyoubTorabi commented 5 years ago

Fatal error: Uncaught TypeError: Return value of controllers\Admin::getAuthController() must be an instance of controllers\AuthController, instance of controllers\BaseAuthController returned in C:\Users\user\Desktop\PHP\pay\app\controllers\Admin.php:9 Stack trace: #0 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\auth\WithAuthTrait.php(83): controllers\Admin->getAuthController() #1 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\auth\WithAuthTrait.php(52): controllers\Admin->_getAuthController() #2 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(139): controllers\Admin->isValid('index') #3 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(30): Ubiquity\controllers\Startup::runAction(Array, true, true) #4 C:\Users\user\Desktop\PHP\pay\vendor\phpmv\ubiquity\src\Ubiquity\controllers\Startup.php(98): Ubiquity\controllers\Startup::_preRunAction(Array, true, true) #5 C:\Use in C:\Users\user\Desktop\PHP\pay\app\controllers\Admin.php on line 9 Admin.php <?php namespace controllers; use Ubiquity\controllers\admin\UbiquityMyAdminBaseController; use Ubiquity\controllers\auth\WithAuthTrait;

class Admin extends UbiquityMyAdminBaseController{ use WithAuthTrait; protected function getAuthController(): AuthController { return new BaseAuthController(); } }

jcheron commented 5 years ago

@AyoubTorabi There was an error in the guide about _isValidUser The correct declaration is: public function _isValidUser($action=null){} Fixed in https://github.com/phpMv/ubiquity/issues/53

The documentation has been updated accordingly (see Guide Auth)

AyoubTorabi commented 5 years ago

I had already added but did not work. Validation also does not appear in the /admin address. Code Source Address: https://justpaste.it/27ncd

This section(AUTH)and CRUD, if the bootstrap theme has been installed and active, will not load "Create Special Controller" button this notification on it "No scaffold with an active theme" Please test source code of example and share with me

jcheron commented 5 years ago

It's still an import issue. You are missing the import of AuthController

use Ubiquity\controllers\auth\AuthController;

Admin controller:

namespace controllers;

use Ubiquity\controllers\admin\UbiquityMyAdminBaseController;
use Ubiquity\controllers\auth\AuthController;
use Ubiquity\controllers\auth\WithAuthTrait;

class Admin extends UbiquityMyAdminBaseController {
    use WithAuthTrait;

    protected function getAuthController(): AuthController {
        return new BaseAuthController();
    }
}
jcheron commented 5 years ago

Indeed, Auth and CRUD scaffolding sections are currently only available with Semantic-ui

jcheron commented 5 years ago

The Auth scaffolding part is implemented in Ubiquity-demo project