composer global require fxp composer asset plugin

Используя fxp/composer-asset-plugin

По сравнению с asset-packagist, composer-asset-plugin не требует изменять конфигурацию приложения. Вместо этого, требуется установить специальный глобальный пакет Composer, выполнив следующую команду:

Эта команда устанавливает composer asset plugin глобально, что позволит устанавливать зависимости из Bower и NPM. После установки все проекты на вашем комьютере будут поддерживать установку Bower и NPM пакетов, описанных в composer.json .

Добавьте следующие строки в composer.json вашего проекта, чтобы указать директории, в которые будут установлены необходимые Bower и NPM пакеты:

Note: fxp/composer-asset-plugin выполняет команду composer update существенно дольше, по сравнению с asset-packagist.

После настройки Composer для поддержки Bower и NPM пакетов:

  1. Исправьте файл composer.json Вашего приложения или расширения и включите пакет в список в раздел require . Следует использовать bower-asset/PackageName (для Bower пакетов) или npm-asset/PackageName (для NPM пакетов) для обращения к соответствующей библиотеке.
  2. Выполните composer update
  3. Создайте класс комплекта ресурсов и перечислите JavaScript/CSS файлы, которые Вы планируете использовать в Вашем приложении или расширении. Вы должны задать свойство [[yiiwebAssetBundle::sourcePath|sourcePath]] как @bower/PackageName или @npm/PackageName .

Это происходит потому, что Composer устанавливает Bower или NPM пакет в директорию, соответствующую этим псевдонимам.

Note: В некоторых пакетах файлы дистрибутива могут находиться в поддиректории. В этом случае, Вы должны задать поддиректорию как значение [[yiiwebAssetBundle::sourcePath|sourcePath]]. Например, [[yiiwebJqueryAsset]] использует @bower/jquery/dist вместо @bower/jquery .

The Composer Asset Plugin allows you to manage project assets (css, js, etc.) in your composer.json without installing NPM or Bower.

This plugin works by transposing package information from NPM or Bower to a compatible version for Composer. This allows you to manage asset dependencies in a PHP based project very easily.

The next major version of Composer Asset Plugin is so different, but also incompatible with the current version, that it became a new project named Foxy.

Foxy is the new way to manage the assets of PHP libraries, because it works nativelly with all the features of NPM or Yarn. However, this plugin will continue to be maintained by the community, without having new features.

Features include:
  • Works with native management system versions of VCS repository of composer
  • Works with public and private VCS repositories
  • Lazy loader of asset package definitions to improve performance
  • Import filter with the dependencies of the root package and the installed packages, for increased dramatically the performance for the update
  • Automatically get and create an Asset VCS repository defined in:
    • NPM Registry
    • Bower Registry
    • Private Bower Registry
  • Automatically get and create the Asset VCS repositories of dependencies defined in each asset package (dev dependencies included)
  • Mapping conversion of asset package to composer package for:
    • NPM Package — package.json
    • Bower Package — bower.json
  • Conversion of Semver version to the composer version
  • Conversion of Semver range version to the composer range version
  • Conversion of dependencies with URL to the composer dependencies with the creation of VCS repositories
  • Conversion of multiple versions of the same dependency to different dependencies of composer
  • Add manually the multiple versions of a same dependency in the project
  • Add a custom config of VCS Repository
  • Override the config of VCS Repository defined by the asset registry directly in config section of root composer
  • VCS drivers for:
    • Git
    • GitHub (compatible with repository redirects)
    • Git Bitbucket
    • Mercurial
    • Mercurial Bitbucket
    • SVN
    • Perforce
  • Local cache system for:
    • package versions
    • package contents
    • repository redirects
  • Custom asset installers configurable in the root file composer.json
  • For Bower, all files defined in the section ignore will not be installed
  • Disable or replace the deleting of the ignore files for Bower
  • Enable manually the deleting of the ignore files for NPM
  • Use the Ignore Files Manager in the Composer scripts
  • Configure the plugin per project, globally or with the environment variables
  • Compatible with all commands, including:
    • depends
    • diagnose
    • licenses
    • remove
    • require
    • search (bower only)
    • show
    • status
Why this plugin?

There already are several possibilities for managing assets in a PHP project:

  1. Install Node.js and use NPM or Bower command line in addition to Composer command line
  2. Do #1, but add Composer scripts to automate the process
  3. Include assets directly in the project (not recommended)
  4. Create a repository with all assets and include the composer.json file (and use Packagist or an VCS Repository)
  5. Add a package repository in composer.json with a direct download link
  6. Create a Satis or Packagist server
  7. Other?

It goes without saying that each javascript, CSS, etc. library should be developed with the usual tools for that language, which front-end developers know well. However, in the case of a complete project in PHP, it shouldn’t be necessary to use several tools (PHP, Nodejs, Composer, NPM, Bower, Grunt, etc.) to simply install these assets in your project.

This plugin has been created to address these issues. Additionally, most developers will not add a composer.json file to their projects just to support php based projects, especially when npm and/or bower already exist and are widely used.

Documentation

The bulk of the documentation is located in Resources/doc/index.md :

Installation

All the installation instructions are located in documentation.

License

This composer plugin is under the MIT license. See the complete license in:

About

Fxp Composer Asset Plugin is a François Pluchino initiative. See also the list of contributors.

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

Установил последней версии composer Поставил последнюю версию composer-asset-plugin 1.2.0

Пытаюсь установить yii2 через композер composer create-project —prefer-dist yiisoft/yii2-app-basic basic Вылетает ошибка

  • yiisoft/yii2 2.0.9 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
    • yiisoft/yii2 2.0.8 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.*@stable -> no matching package found.
    • yiisoft/yii2 2.0.7 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.*@stable -> no matching package found.
    • yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
    • yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
    • Installation request for yiisoft/yii2 >=2.0.5 -> satisfiable by yiisoft/yii2[2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9].

Погуглив, рецепта не нашел. Все равно вылетает одна и та жа ошибка. Подскажите, плиз, что делать.

Решил все снести и заново поставить композер на макбук согласно инструкции https://www.abeautifulsite.net/installing-composer-on-os-x

sudo mv composer.phar /usr/local/bin/

alias composer=»php /usr/local/bin/composer.phar»

Далее через терминал поставил плагин composer global require «fxp/composer-asset-plugin:^1.2.0» (папки bower-asset в папке .composer не обнаружил)

Запустил через терминал в рабочей папки composer create-project —prefer-dist yiisoft/yii2-app-basic basic и вылетают те же самые ошибки, что требуется requires bower-asset/jquery 2.*@stable

пробуя разные советы из форумах и на стековерфлоу так и не смог разобраться почему не ставится bower-asset/jquery через плагин fxp/composer-asset-plugin (пробовал разные версии)

в итоге поставил yii2 в ручную, но все же не дает пок, чем вызвана проблема с композером. У кого были похожие проблемы с установкой на мак плиз отпишите как их решали. Спасибо!

Оцените статью