简体   繁体   中英

Composer and Yii

I'm using composer as my dependency manager and since I need to develop with Yii Framework I added it to my composer.json file, so it looks like this:

//other properties...
"require": {
    //other dependencies...
    "yiisoft/yii": "dev-master"
}

Composer.json is ok, Yii downloaded correctly, but there is a feature I think composer misses. My yii directory now is full of "rubbish", demo folders, build files bla bla that I don't really need. There is a way to tell composer to keep only some directory and throw away the others?

With composer we work in a different way. With composer our application take care only of its code. In fact, if you kork with git, you must add yii folder to .gitignore couse is not your application folder. This is the symfony way.

What about Yii!? First of all I suggest you to start yii projects with:

$ composer create-project yiisoft/yii path/to/your/project

This is the Yii way to work with yii and composer. After that, when you finish to dowload yii, composer ask you if you want to keep or not yii's git files. You can simply say no, and remove manually these files. You can also try to fork yiisoft/yii and improve this behavior so this removing stuffs will happen automatically.

I had the exact same issue, so I ended up repackaging Yii so that it only contains the framework folder. It reduces the package by ~10Mb. Here's a link to the github repo .

Just add the following to your composer.json file.

{
    "require": {
        "square1-io/yii-framework": "1.1.14"
    }
}

Then run:

$ composer install

I've thrown up a blog post about it: http://blog.square1.io/post/60830077608/yii-1-1-14-via-composer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM