Yii Framework Forum: [Wiki] How To Use The Official Yii Installer For Composer - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Wiki] How To Use The Official Yii Installer For Composer questions Rate Topic: -----

#1 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 644
  • Joined: 29-November 08
  • Location:Paris, France

Posted 05 April 2013 - 02:56 AM

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)
0

#2 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 03:34 AM

View PostRaoul, on 05 April 2013 - 02:56 AM, said:

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.
0

#3 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 April 2013 - 06:07 AM

Hi guys,

the .lock file is important, don't remove it:
http://getcomposer.o...k-the-lock-file

Quote

This is important because the install command checks if a lock file is present, and if it is, it downloads the versions specified there (regardless of what composer.json says). This means that anyone who sets up the project will download the exact same version of the dependencies.


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
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#4 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 644
  • Joined: 29-November 08
  • Location:Paris, France

Posted 05 April 2013 - 06:23 AM

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)
0

#5 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 06:24 AM

View Postschmunk, on 05 April 2013 - 06:07 AM, said:

the .lock file is important, don't remove it:
http://getcomposer.o...k-the-lock-file

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.
0

#6 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 06:27 AM

View PostRaoul, on 05 April 2013 - 06:23 AM, said:

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 ?

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
0

#7 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 April 2013 - 06:37 AM

Heya, some words about the current installer for Yii in composer:
http://www.yiiframew...post__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.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#8 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 06:59 AM

View Postschmunk, on 05 April 2013 - 06:37 AM, said:

Heya, some words about the current installer for Yii in composer:
http://www.yiiframew...post__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.
0

#9 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 April 2013 - 07:14 AM

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.

Quote

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.

No, what should break?
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#10 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 08:01 AM

View Postschmunk, on 05 April 2013 - 07:14 AM, said:

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.


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.
0

#11 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 April 2013 - 09:42 AM

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.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#12 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 05 April 2013 - 12:53 PM

View Postschmunk, on 05 April 2013 - 09:42 AM, said:

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.
0

#13 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 05 April 2013 - 05:43 PM

Why do you need to install packages into extensions/ and modules/?
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#14 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 06 April 2013 - 03:34 AM

View Postschmunk, on 05 April 2013 - 05:43 PM, said:

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.
0

#15 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 07 April 2013 - 12:49 PM

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.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#16 User is offline   br0sk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 16-February 09

Posted 07 April 2013 - 01:44 PM

View Postschmunk, on 07 April 2013 - 12:49 PM, said:

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....
0

#17 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 568
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 07 April 2013 - 02:00 PM

I posted my concerns on composer-dev ... let's see what they'll say.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users