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

Bower packages with BowerRepository #3078

Closed
wants to merge 3 commits into from
Closed

Conversation

nsams
Copy link

@nsams nsams commented Jun 27, 2014

(copy of post to composer-dev mailing list to reach larger audience)

I want to manage javascript dependencies for my projects.

As far as I can see possible options are:

  1. Don't use composer for that, use an external tool eg. bower
    • inconvenient install (composer install + bower install is required
    • additional dependencies (you need node+bower)
    • composer packages can't have bower dependencies (that's the big issue for me)
  2. Put javascript dependencies into shim composer packages
    • doesn't allow usage of existing bower infrastructure
    • requires quite some effort
  3. integrate bower into composer
    • would re-use the existing composer infrastructure
    • would support composer.lock (which is very important for me)

Related Discussion: #1121

I implemented a first prototype for (3) where I created a BowerRepository similar
to PearRepository that allows installing bower packages. (This is still work in progress and has many rough edges - I just want to get early feedback)

Example usage:

$ cat composer.json 
{
    "repositories": [
        {
            "type": "bower",
            "url": "http://bower.herokuapp.com"
        }
    ],
    "require": {
        "bower/jquery": "1.11.*",
        "bower/backbone": "*"
    }
}

$ ../composer/bin/composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing bower/jquery (1.11.1)
    Loading from cache

- Installing bower/underscore (1.6.0)
    Loading from cache

- Installing bower/backbone (1.1.2)
    Loading from cache

Writing lock file
Generating autoload files

Now my question is if this is a good idea that you are willing to integrate into composer.
Or any other thoughts you might have about this...

bower package seem to use this modifier
…ire a real package object

this especially improves performance for packages with many tags, eg jquery
@nsams nsams changed the title Bower Bower packages with BowerRepository Jun 27, 2014
@cebe
Copy link
Contributor

cebe commented Jun 29, 2014

interesting... I started today with another approach to this: https://github.com/cebe/composer-bower
Had not seen your PR before.

@creocoder
Copy link

I want to manage javascript dependencies for my projects.

Take bower or any frontend package manager and manage js dependencies. No need pervert composer ideas please. It php package manager. It not package manager for everything.

@cebe
Copy link
Contributor

cebe commented Jun 29, 2014

@creocoder how does your statement here compares to that one? yiisoft/yii2#3209 (comment) :) Why did you changed your mind?

@nsams
Copy link
Author

nsams commented Jun 29, 2014

@cebe also an interesting approach that would solve the problem. Especially the part that you don't need any changes to composer itself it nice.

Imho my approach also has advantages:

  • doesn't depend on an additional server, uses bower infrastructure only
  • new releases/packages will be available without delay (as there I request github directly)
  • I don't run into github api limits

@cebe
Copy link
Contributor

cebe commented Jun 29, 2014

@nsams how do you cover the conversion of bower version constraints into a format that composer can understand as described here: cebe/composer-bower#2 ?
Do not see something about that in your code...

@nsams
Copy link
Author

nsams commented Jun 29, 2014

@cebe not at all so far. It's an prototype I want to get early feedback for...

@nsams
Copy link
Author

nsams commented Jun 29, 2014

@creocoder in practice many composer packages exist of php + frontend code AND has dependencies on other frontend packages. How to solve that?

Another important feature is missing in bower: composer.lock

@creocoder
Copy link

@cebe

Why did you changed your mind?

Because this is best practice of web dev.

in practice many composer packages exist of php + frontend code

Can you show any famous js library with composer.json inside instead of bootstrap? Last time we try to make PR for js library it was rejected with comment like: "Go to hell with composer.json in this js repo, use bower". After some though i realize that this is only way to do things right.

@cebe
Copy link
Contributor

cebe commented Jun 29, 2014

@creocoder how do you suggest solving the existing problem then? You currently can not define dependency of composer php project on js library cleanly although the dependency exists.

Note that the solution does not require the JS repos to contain a composer.json, all info is read from existing bower.json.

@nsams
Copy link
Author

nsams commented Jun 29, 2014

Can you show any famous js library with composer.json inside instead of bootstrap? Last time we try to make PR for js library it was rejected with comment like: "Go to hell with composer.json in this js repo, use bower". After some though i realize that this is only way to do things right.

I can understand why they don't want a package definition for every package manager on earth in their repo. They even would have to maintain it themselves.

But that's the whole point of my pull request and cebe/composer-bower: both work with the existing bower.json and make it usable for composer.

@creocoder
Copy link

@cebe

how do you suggest solving the existing problem then? You currently can not define dependency of composer php project on js library cleanly although the dependency exists.

I see NO ANY problems really. Just write in your extension README what version of frontend package is required and user will get this version using any frontend package manager, using any way he like. Someone will use bower, someone will use component, someone will use package manager which will be developed in future. MOST important that this will be frontend package manager which can be used with any backend language. There is all clean in web dev. We have backend package managers (individual per language used) and frontend package managers.

If you plan write into your composer.json any depencies of frontend packages this backend package will not be used, because you insist on your way of getting frontend package and this is BIG mistake. Because this is just out of normal web dev workflow. Such backend packages will be "very smart" white crows and i belive no one will use that.

@cmfcmf
Copy link

cmfcmf commented Jun 29, 2014

I see NO ANY problems really. Just write in your extension README what version of frontend package is required and user will get this version using any frontend package manager

Imagine I create a CMS and use composer for php dependencies. You suggest, that I require all my potential users (who never programmed anything, have no idea about javascript, package managers, etc.) to search the web and download dependencies by hand (or using a package manager they never heard of), before they can use my CMS? 😏

@francoispluchino
Copy link
Contributor

I think it is better to go through the plugin system and not included the system directly in Composer. It is for this reason that I created a plugin for accessing to files package.json for NPM and bower.json for Bower, through the automatic creation of VCS Repository.

Currently the plugin only works in global mode, but there is a PR #3082 waiting, for restart the installation after installing plugins, and in this case, the plugin can be added directly to the project dependencies.

@creocoder
Copy link

@cmfcmf

Imagine I create a CMS and use composer for php dependencies. You suggest, that I require all my potential users (who never programmed anything, have no idea about javascript, package managers, etc.) to search the web and download dependencies by hand (or using a package manager they never heard of), before they can use my CMS?

Ofcourse not. You need use bower or anyother frontend package manager for manage frontend packages. You need use composer or any php package manager for manage backend packages. You run it before distribute your CMS, also you run composer ofcource and distribute CMS with all files included. I do not even understand what trouble you talking about? bower and comoser tools for developers, not users. No need say that composer known by everybody. Compare composer and bower popularity and i think you'll understand something new.

@cmfcmf
Copy link

cmfcmf commented Jun 29, 2014

Ofcourse not. You need use bower or anyother frontend package manager.

Well, I'd like to use composer though 😏 However, I won't discuss this further, I just hope there will be bower support in composer at some point 🍃

@francoispluchino
Copy link
Contributor

@cmfcmf If you are interested by this feature, you can always test this plugin

@cmfcmf
Copy link

cmfcmf commented Jun 29, 2014

@francoispluchino Yeah, I will tinker around with it.

@nsams
Copy link
Author

nsams commented Jun 30, 2014

@francoispluchino wow, amazing! With that I think we can close my PR 😄

@nsams
Copy link
Author

nsams commented Jul 15, 2014

closing this PR in favor of https://github.com/francoispluchino/composer-asset-plugin

@nsams nsams closed this Jul 15, 2014
@nsams
Copy link
Author

nsams commented Sep 14, 2014

Another alternative for installing asset packages:

http://www.nikosams.net/blog/17_composer_npm_bower_assets_installation_using_composer-extra-assets

@cebe cebe mentioned this pull request Sep 14, 2014
5 tasks
@trntv
Copy link

trntv commented Sep 17, 2014

I think that a js and css packages are the same big part of php ecosystem as php packages are. So the next logical evolutional step is a package manager that can combine many package repositories (composer, bower, npm or even linux repositories) together. imho

@francoispluchino
Copy link
Contributor

@trntv See fxp/composer-asset-plugin

@trntv
Copy link

trntv commented Sep 17, 2014

@francoispluchino already working with it ;)

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

Successfully merging this pull request may close these issues.

None yet

6 participants