composer autoloader bug #81

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

Comments

Projects
None yet
3 participants
@mitalcoi

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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 19, 2013

Owner

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?

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

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jun 19, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 19, 2013

Owner

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.

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

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jun 19, 2013

maybe use namesapces?

maybe use namesapces?

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 19, 2013

Owner

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

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

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jun 19, 2013

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

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

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 19, 2013

Owner

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?

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 Jun 19, 2013

@mitalcoi

This comment has been minimized.

Show comment
Hide comment
@mitalcoi

mitalcoi Jun 19, 2013

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

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

@ujovlado

This comment has been minimized.

Show comment
Hide comment
@ujovlado

ujovlado Jun 19, 2013

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"
    }
}
Contributor

ujovlado commented Jun 19, 2013

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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 20, 2013

Owner

I am gonna add that to the docs :)

Owner

Sammaye commented Jun 20, 2013

I am gonna add that to the docs :)

@ujovlado

This comment has been minimized.

Show comment
Hide comment
@ujovlado

ujovlado Jun 20, 2013

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.

Contributor

ujovlado commented Jun 20, 2013

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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 20, 2013

Owner

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

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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye Jun 20, 2013

Owner

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

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