myth-auth
myth-auth copied to clipboard
AuthController in App folder not responding on auth:publish
Hi,
I'm not sure if this should be marked as a bug but i just found out a small issue that could only be resolved by changing the vendor package.
Situation I needed to load a helper inside the controller, this did nothing an didn't even respond clearing the entire file in the App folder. Changing this value in the vendor folder (not recommended) did the trick and actually worked. Is this something that has to work this way or i'm I doing something wrong?
Wat i need
Set the BaseController as extends in App\Controller\AuthController.php
so it's possible to load helper functions.
<?php
// Current
class AuthController extends Controller
// I need
class AuthController extends BaseController
Hi i think the solution is to extend AuthController in to your App\Controller\ folder
Example: `use Myth\Auth\Controllers\AuthController as MythAuthController;
class AuthController extends MythAuthController {
public function __construct() { parent::__construct(); helper('text'); }
// Other functions here if needed } `
@kpeu3u good point! Unfortunately this doesn't work either, still the error as shown below:
Call to undefined function form_open()
Hi i think the solution is to extend AuthController in to your App\Controller\ folder
Example: `use Myth\Auth\Controllers\AuthController as MythAuthController;
class AuthController extends MythAuthController {
public function __construct() { parent::__construct(); helper('text'); }
// Other functions here if needed } `
@bedrijfsportaal change the helper('text')
to helper('form')
it will load the form helper
Hello @mjamilasfihani Thank you for the feedback! You have a good eye i totally missed that on @kpeu3u comment :) but it makes no difference on my side because i've written it myself so no copy/paste answers.
I think the AuthController isn't loaded inside the App folder because it makes no difference what change i've made it's not loading or changing anything.
Hello @mjamilasfihani Thank you for the feedback! You have a good eye i totally missed that on @kpeu3u comment :) but it makes no difference on my side because i've written it myself so no copy/paste answers.
I think the AuthController isn't loaded inside the App folder because it makes no difference what change i've made it's not loading or changing anything.
You are welcome, glad to hear that good news :)
No news as it's still not working like i mentioned in my previous comment..
Well, since you've already published the AuthController
in your App folder, you can try either of the following:
- Add a
protected $helpers
variable to store your helpers in an array like so:
protected $helpers = ['form'];
- Inherit the autoloading feature from the
BaseController
. So, your file should be updated to:
<?php namespace App\Controllers;
use App\Controllers\BaseController;
class AuthController extends BaseController {
// code goes here
}
instead of:
<?php namespace App\Controllers;
use CodeIgniter\Controller;
class AuthController extends Controller {
//
}
Hello Sammyskills,
The first solutions isn't working either, tested this already on my end. The second solution is a published file from the GIT, when running "php spark auth:publish" the files will be copied to the App folder.
It's only a simple funtion so the world wouldn't end, but if I wish to extend this class there would be a mayor issue since i'm unable to extend the class itself.
Forgot to mention it's a Composer installation.
Is this still actual?
Hi,
Situation I needed to load a helper inside the controller, this did nothing an didn't even respond clearing the entire file in the App folder. Changing this value in the vendor folder (not recommended) did the trick and actually worked. Is this something that has to work this way or i'm I doing something wrong?
Wat i need Set the BaseController as extends in
App\Controller\AuthController.php
so it's possible to load helper functions.
There is no need to extend BaseController to load some helper. just use helper() function. That's all.
In your case i guess you forgot to change default routes after publishing your controller to App folder. Check it please and let me know about result. I already checked helper in AuthController inside App folder which extends CI's Controller. Everything works fine, helpers loaded.
Closing as stale. Fell free to reopen it if you need.