Welcome Guest, Not a member yet? Register   Sign In
Upgrade to 2.0.1 - config/autoload.php not loading
#1

[eluser]Webnet[/eluser]
I just upgraded from 1.7 to 2.0.1 following the upgrade guide. I'm getting an error that indicates my autoload classes aren't being loaded before the page's controller, so I added

Code:
echo "test";
exit;

to the config/autoload.php and it's still loading the controller before these configurations. I'm not sure where I should begin testing as to what could be the problem, any suggestions?
#2

[eluser]Phil Sturgeon[/eluser]
The user guide there covers most things, but I feel that my instructions might be a little more in depth. They also have some invaluable comments on them so it could help you out:

http://philsturgeon.co.uk/news/2010/05/u...gniter-2.0

Can you post us up your autoload?
#3

[eluser]Webnet[/eluser]
I looked over your guide, It covered the same things I did. We don't use plugins, ecryption, or validation provided by CI so there wasn't as much to be concerned with.

Here's the start of my autoload

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

echo 'test';
exit;

/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
*/

......................

$myLibraries= array(
    'helper',
    'MY_controller'
);

$autoload['libraries'] = array_merge(array('session', 'form_validation', 'database', 'datamapper', 'model', 'summary'), $myLibraries);
#4

[eluser]Phil Sturgeon[/eluser]
That seems overly complicated and inaccurate. You cannot load MY_controller as a library because it is not a library, even if some tutorials (such as mine here http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY suggest you put it in that folder.

Follow my tutorial and it should work fine for you. Especially moving it to the application/core folder.
#5

[eluser]Webnet[/eluser]
Phil,

I might just be misunderstanding, but I don't quite see how the tutorial helps. I should point out that I'm completely new to CodeIgniter, I've been put into a project at work that uses it having never used it before. I'm trying to get started on the right foot - starting with upgrading our version of CI.

-- The more I look at it, this seems like a hackish way of accomplishing this. Is there no better method that's supported by CI?
#6

[eluser]Phil Sturgeon[/eluser]
Take MY_Controller out of autoload, that wont work. What content are you trying to autoload that is not working?

Explain what the problem is and I can give more accurate advice.
#7

[eluser]Webnet[/eluser]
Disclaimer: I didn't set this up!!!

MY_controller.php is:

Code:
<?php
class MY_Controller {}

require_once 'abstract_controller.php';
?>

abstract_controller.php is our actual base controller that's used everywhere. I'm not entirely sure the best way to change this setup.

Code:
class AbstractController extends CI_Controller

Where should I put MY_controller.php? How should it be included so that I have access to it? Is there a better way than the catch all __autoload() ?
#8

[eluser]Phil Sturgeon[/eluser]
Yeah that won't work. Just put AbstractController in as class MY_Controller extends CI_Controller, put it in the application/core folder and extend MY_Controller.
#9

[eluser]Webnet[/eluser]
I updated my last post just before you responded.

Now, I'm just now upgrading to 2.0, we haven't had a core folder until now. Where should I put the __autoload ? I can't think of a good place that would be outside of CodeIgniter.
#10

[eluser]Phil Sturgeon[/eluser]
That is why I suggested you read my article. __autoload() goes at the bottom of config.php.




Theme © iAndrew 2016 - Forum software by © MyBB