CodeIgniter Forums
Name Collisions with autoload (best guess) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Name Collisions with autoload (best guess) (/showthread.php?tid=53785)



Name Collisions with autoload (best guess) - El Forum - 08-08-2012

[eluser]micha8l[/eluser]
Here's part of my directory structure:
Code:
application/
    models/
        _administrator/
            article_category_model.php
        article_category_model.php
    controllers/
        _administrator/
        article.php
    article.php

I $autoload['article_category_model'] using config file.

In my "application/controllers/_administrator/article" controller I have this code:
Code:
class Article extends Administrator_controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function issue()
    {
        $this->load->model('_administrator/article_category_model');

        // HERE'S WHERE IT DOESN'T WORK -- I JUST GET BLANK SCREEN
        $this->article_category_model->create_issue();
    }
}

It seems that when I call article_category_model's create issue method, CI will search for the method in "application/models/article_category_model.php" instead of "application/models/_administrator/article_category_model.php".

Please help, how can I fix this, 3 hours I've been at this!


Name Collisions with autoload (best guess) - El Forum - 08-09-2012

[eluser]Aken[/eluser]
Blank screen = error. Turn error reporting on in your php.ini file / locally in index.php, and see what the error says. Debug from there.

You cannot declare the same class name in PHP, even if they're in different files in different directories. Your model class names must be different.


Name Collisions with autoload (best guess) - El Forum - 08-09-2012

[eluser]micha8l[/eluser]
[quote author="Aken" date="1344499369"]Blank screen = error. Turn error reporting on in your php.ini file / locally in index.php, and see what the error says. Debug from there.

You cannot declare the same class name in PHP, even if they're in different files in different directories. Your model class names must be different.[/quote]

Thanks for correcting me on that Aken, blank screen is indeed error. However error reporting is on, as I've tested it -- this is something else.

However I did not know I could not declare same class name, I'm newbie and my cracks are showing Big Grin

And so I look into namespaces http://www.php.net/manual/en/language.namespaces.rationale.php