Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composer autoloader bug #81

Closed
mitalcoi opened this issue Jun 19, 2013 · 13 comments
Closed

composer autoloader bug #81

mitalcoi opened this issue Jun 19, 2013 · 13 comments

Comments

@mitalcoi
Copy link

if we use composer autoloader we have an error "include(EMongoClient.php): failed to open stream: No such file or directory". we have this errors beacause at EMongoModel on string 505 we have strange place:

  self::$db=Yii::app()->mongodb;

I think we need to rewrite this place to avoid problem with psr-0

@Sammaye
Copy link
Owner

Sammaye commented Jun 19, 2013

I need to test with composer, if I am honest I have never used it (haven't found the time yet :) however, shouldn't the configuration in the main.php handle the psr-0 for getting the mongodb component?

@mitalcoi
Copy link
Author

yes, we can write something like

            'import' => array(
                'vendor.sammaye.mongoyii.EMongoClient',
            ),

and it will be work, but
my opinion is that we shouldn't use the context Yii (Yii::app()->mongodb) into the the extension classes because this breaks opportunity of clear autoload. If you change it to traditional OOP-chema, it will be good

@Sammaye
Copy link
Owner

Sammaye commented Jun 19, 2013

What do you mean by OOP schema?

The problem with changing this part is that the mongodb component configuration is a dependancy of the MongoYii extension. The only other way to solve this with Yii 1's structure is to enforce that the user enters the connection object in every instantiation of the class, otherwise there is no easy and automatic way to understand wehat connection the user wants to be used really.

@mitalcoi
Copy link
Author

maybe use namesapces?

@Sammaye
Copy link
Owner

Sammaye commented Jun 19, 2013

The only problem with doing that is that it currently breaks everyones autoloading, such tactics would only work for people using composer, anyone else would have to completely rewrite their autoloading patterns around: http://www.yiiframework.com/doc/guide/1.1/en/extension.integration

Namespaces are not that well supported in Yii1 and I am trying to leave them off to Yii2 for that reason

@mitalcoi
Copy link
Author

ok. so, we will be wait for Yii-2 :)

@Sammaye
Copy link
Owner

Sammaye commented Jun 19, 2013

Indeed :) it is definitely there for Yii2, got a lot of good plans for Yii2 when they get out of public preview.

To be honest I was thinking of trying to get a least the core of MongoYii placed in the core of Yii 2, I see they will be supporting NoSQL databases as standard now so if I rush in with something I might get it into the core.

But anyway I am gonna close this task for the moment if that's ok?

@Sammaye Sammaye closed this as completed Jun 19, 2013
@mitalcoi
Copy link
Author

it would be wonderful if your extension would be included in the core Yii2

@ujovlado
Copy link
Contributor

I think there's no need to use autoload from composer to use MongoYii extension. Just use composer/installers, define installer-paths and then use standard import method in your config.

This is part from my composer.json:

{
    "require": {
        "composer/installers": "~1.0",
        "yiisoft/yii": "1.1.13",
        "sammaye/mongoyii": "1.2.9"
    },
    "extra": {
        "installer-paths": {
            "protected/extensions/{$name}": ["sammaye/mongoyii"]
        }
    }
}

I have Yii installed in standard vendor dir.

If you're using only extensions through Composer, solution can be set vendor-dir to protected/extensions:

{
    "config": {
        "vendor-dir": "protected/extensions"
    }
}

@Sammaye
Copy link
Owner

Sammaye commented Jun 20, 2013

I am gonna add that to the docs :)

@ujovlado
Copy link
Contributor

Oh, wait, this is not true with next version (1.0.4) of composer/installers, which was released 6 hours ago (and match ~1.0).

So solution can be:

Sorry for misunderstanding.

@Sammaye
Copy link
Owner

Sammaye commented Jun 20, 2013

Ah yes, the Yii installer has been deprecated (http://www.yiiframework.com/wiki/473/how-to-use-the-official-yii-installer-for-composer-deprecated/); I was going to ask that but it seemed like that would work regardless for a min.

I will amend it after I have finished proof reading

@Sammaye
Copy link
Owner

Sammaye commented Jun 20, 2013

Updated the documentation to reflect that, I will update all doc sources now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants