[Wiki] How To Use The Official Yii Installer For Composer

this post is related to the "How to use the official Yii installer for Composer" wiki post.

Thanks brOsk for this intresting post.

…just one question : how come creating a new yii webapp produces the composer.lock file (chapter Create a new web application) ?

Another point is that you don’t need to install composer for each new webapp right ?

ciao

B)

The lock file was there by accident. I initially tried installing Yii via Composer and forgot to remove the lock file. Thanks for pointing it out :)

I added a section with a link for how to install Composer globally instead of in every web app.

Thanks for the comments feel free to give me more feedback :)

I will add this forum post to the Wiki.

Hi guys,

the .lock file is important, don’t remove it:

http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file

If you’re developing a project, you should run composer update on purpose, not only to “download” your packages.

Running update may give you another set of packages, depending on your constraints in the composer.json file.

But composer install will install the exact same versions of packages on every machine where you run it, e.g.




git clone

composer.phar install


git pull

composer.phar install



That should actually be a githook in your project.

Best regards,

schmunk

The more I play with composer the more I like it … I plan to provide a composer.json file for my (few) published yii extensions.:)

One question : wouldn’t it be useful to add a ‘theme’ location in the Yii Installer ? ‘module’ and ‘extension’ are all right, but a ‘theme’ would also be a good candidate wouldn’t it ?

ciao

B)

Don’t worry about this. At the point in the tutorial where I mentioned the lock file I had not even started to use Composer. The lock file will automatically be added in this step Run a composer update of course.

It was just not logical that it was displayed in the list of files and folder to be found in the installation folder.

It sounds like that could be useful. I guess you could fork the installer code and add support for the or ask the people working on it to include it.

Have a look here github.com/composer/installers/pull/61

Heya, some words about the current installer for Yii in composer:

http://www.yiiframework.com/forum/index.php/topic/39669-composer-support/page__view__findpost__p__199279

Sound a bit like a rant, I am sorry ;) But as layed out in the posting, simply there are glitches.

I’d only distinguish between “yii-extension” and “yii-theme”. “yii-module” is not necessary, IMHO.

But getting the right location for a theme, if you’ve reconfigured it, is a problem from the installer. Let me know if you’ve a solution for that.

If all rants were as informative as that I take a rant any day ;)

The installers are very basic and the custom functionality you have built is way more powerful than what a plain installer can give. I mostly wrote the Wiki to get a discussion going for a unified solution for Composer and Yii 1.1.x. from looking at the thread you mention it sounds like both you and me are ahead of the Yii dev team when it comes to using Composer… I don’t really care what the end solution will be as long as it is flexible and light enough. A bonus would be if it was very similar to what we will get in Yii2.

When it come to installing to specific folders for each extension is this what you mean?




"extra": {

    "installer-paths": {

    "protected/extensions2/{$name}/": ["br0sk/yiiron", "anothervendor/anotherextension"],

    "protected/modules2/${name}/": ["br0sk/module1", "br0sk/module2"]

    }

}



You can find more info about this in my wiki.

On a side note, will defining my extension as type yii-extension break if I try to use the Phundament Composer repository? If so we might have a problem.

I really appreciate your work, because I also try to use a slim approach, if possible,

I totally agree with you, that it would be awesome if the composer integration for Yii 1.x is similar to Yii2. Let’s combine our efforts :)

As an example I learned about the multiple installer paths from your wiki article.

But my problem here is simply that I don’t want to mix code I get from composer with my project code, see also this composer FAQ.

No, what should break?

Tbh I haven’t looked into exactly how the installer you have made is implemented. It is probably a good idea for me to add Yiiron to your repository so I get a feel for how it works.


No, what should break?

I was thinking of if you were using the type in any way or if requiring the installers would mess up anything you have done since it changes the behaviour for where the packages gets installed.

I don’t use installers at all at the moment.

here’s my installer “magic”:

src/Phundament/ComposerCallback takes care of executing the scripts for the specified packages.

That is very nice work. It looks like it is pretty tied in to Phundament. If it is not it might be good to write a Wiki for how to use it free standing from Phundament.

I wasn’t really thinking about redistribution of the application. I can see how that would be a big problem for an application like Phundament or any other full application that is source controlled.

A middle ground for the installer based wiki wrote I wrote could be to use the extension, module and vendor folders for Composer installations only. Make sure these folders are git ignored and commit the composer lock file so that redistribution will be easy. If manual installation of extensions and modules are needed we can create separate folders for them since they have to be committed to Git to be redistributed anyway. The manual installation folders could be prefixed with manual_ or something like that. Not so pretty but as the installers are getting more common we will have less stuff in the manual_ folders and in Yii 2 it will not be needed at all if all extensions and modules are going to be forced to live in Composer anyway.

Another way would be to have subfolders within the extension and module folders but that would make the composer file messier. like so ext.manual.extension1 and ext.composer.extension2. Here we git ignore the path for ext.composer.

I think that would improve the installer based way of using Composer.

Why do you need to install packages into extensions/ and modules/?

I don’t but since the official installer is using those directories I thought it was best to use them. It also seems to be standard Yii behaviour. I am just trying to get people to not having to change much from the standard installation.

Yes, it is the Yii standard behavior that you place extensions and modules into these folders. But doing it with composer is raising a lot of problems in my opinion.

As mentioned it gives you no benefit of placing the stuff into the folders above. Place it into vendor and you’re good to go, with more or less the same amount of config changes.

And I don’t want to be picky, but this is not an official installer from the Yii Dev team.

I guess it is just a matter of taste where you place the installed Composer packages. And the fact that both solutions can do this I think it is OK to do what you like. Though I wonder how it will work in Yii 2…

And no this is not the official installer released by Yii. It is the official Yii installer for Composers, maybe that was not clear enough.

I think I will leave the Wiki as it is for now but continue to plat with the installers to see if I come up with a better way. Just putting everything in the standard vendor folder might actually turn out to be the best thing.

Let me know if you get to know about any new Composer stuff. I think it is crucial to get this right in Yii 2. A PHP framework without proper Composer support will probably be a dead framework in a year or so…

I posted my concerns on composer-dev … let’s see what they’ll say.