benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.34k stars 1.14k forks source link

why the CI_Ion_auth not founded when i go to the other controller #1060

Closed ghost closed 7 years ago

ghost commented 7 years ago

at first controller, which it is for login can access ion auth and worked for login. but after i go to another controller, it said the class was not found. why? image

benedmunds commented 7 years ago

First make sure you have the library file in place and either auto loaded or loaded in this controller.

If you believe you do, post a screenshot of the directory structure.

Also, what version of PHP and CodeIgniter are you using?

-Ben Edmunds

On April 2, 2017 at 11:43:46 AM, seemugia1 (notifications@github.com) wrote:

at first controller, which it is for login can access ion auth and work for login. but after i go to another controller, it said the class was nor found. why? [image: image] https://cloud.githubusercontent.com/assets/25352142/24588619/cae493a8-17f5-11e7-8ab3-8115766e6703.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/1060, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJkl7_swaGx0bUg4ifL-T4Zvm7zmAd-ks5rr8IygaJpZM4Mw1pM .

ghost commented 7 years ago

and last month i used the the site to built it, but yesterday i used it, it became error

benedmunds commented 7 years ago

@seemugia1 please answer the above questions

benedmunds commented 7 years ago

Closing due to inactivity. Please comment if this is stil an issue.

chris-mackie commented 7 years ago

I'm getting this issue too when using wiredesignz hmvc.

image

benedmunds commented 7 years ago

@chrismackie28 post your autoload config please

chris-mackie commented 7 years ago
defined('BASEPATH') OR exit('No direct script access allowed');

/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it.  This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Drivers
| 4. Helper files
| 5. Custom config files
| 6. Language files
| 7. Models
|
*/

/*
| -------------------------------------------------------------------
|  Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in system/libraries/ or your
| application/libraries/ directory, with the addition of the
| 'database' library, which is somewhat of a special case.
|
| Prototype:
|
|   $autoload['libraries'] = array('database', 'email', 'session');
|
| You can also supply an alternative library name to be assigned
| in the controller:
|
|   $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('ion_auth', 'database', 'form_validation');

/*
| -------------------------------------------------------------------
|  Auto-load Drivers
| -------------------------------------------------------------------
| These classes are located in system/libraries/ or in your
| application/libraries/ directory, but are also placed inside their
| own subdirectory and they extend the CI_Driver_Library class. They
| offer multiple interchangeable driver options.
|
| Prototype:
|
|   $autoload['drivers'] = array('cache');
|
| You can also supply an alternative property name to be assigned in
| the controller:
|
|   $autoload['drivers'] = array('cache' => 'cch');
|
*/
$autoload['drivers'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('url','language');

/*
| -------------------------------------------------------------------
|  Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files.  Otherwise, leave it blank.
|
*/
$autoload['config'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file.  For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array('auth');

/*
| -------------------------------------------------------------------
|  Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['model'] = array('first_model', 'second_model');
|
| You can also supply an alternative model name to be assigned
| in the controller:
|
|   $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array();
benedmunds commented 7 years ago

Hmm looks fine.

So it works in the Auth controller but breaks for HMVC controllers?

chris-mackie commented 7 years ago

Works for the HMCV controllers and not Auth

benedmunds commented 7 years ago

Is Auth still extending CI_Controller?

chris-mackie commented 7 years ago

yes, ion_auth is not in modules and extends CI_Controller

benedmunds commented 7 years ago

Maybe try loading Ion Auth as a third party module? I suspect the error is with HMVC's loader, but their docs say third party modules should work.

chris-mackie commented 7 years ago

still doesn't work

benedmunds commented 7 years ago

First, can you ensure this works fine without HMVC on your environment?

Second, is there a forum or place to ask WiredDesigns? I'd probably recommend that next.

If you want to post a full test project up somewhere I'd be happy to try to troubleshoot it. I'd probably start with their loader and debug how it works and if there's a way to tell it how to handle projects outside of HMVC.

chris-mackie commented 7 years ago

I have about 30 other local sites that are working fine with HMVC & ion_auth.

Will check wiredesignz bitbucket now.

Also added you to the repo.

Thanks for your help

benedmunds commented 7 years ago

Got it. Traveling this week and don't have PHP 7 on this laptop so I'm not able to test local.

Try removing the autoloading since you're loading the third party package in the controller. That's the only thing that looks odd with that...

chris-mackie commented 7 years ago

I'll keep trying and keep you updated.

benedmunds commented 7 years ago

Thanks and good luck! Happy to rubber duck anything I can help with.

chris-mackie commented 7 years ago

Turned out to be the MY_Controller I was using.

Seems ok now but allot temperamental in places since I started using CI Version 3.1.5, lets see how it goes.

Thanks again for your help and the super fast response!

benedmunds commented 7 years ago

Ah ok cool, hope it goes smoothly!