I saw a composer.json in some plugins, but how to fetch them?
I tried:
plugin:refresh
composer update (in root dir)
iirc doing composer install or composer update in the plugin's directory will fetch dependencies. That said any plugins installed from the OctoberCMS plugin marketplace will usually install deps automatically.
But if I will update in my plugin dir then it make vendor dir and autoloader class in my plugin dir not in app dir. Ok, I can manually duplicate require record in main composer.json for developing. It's seems weird, no?
And what do you mean."automatically"? Composer is updating during plugin instalation? Can you explain more details, please?
I'm sorry, I was wrong about plugin deps in composer.json. If a plugin uses $require in Plugin.php then the required plugins will be loaded first. For deps required in composer.json you must run composer install in the plugin directory. Once that is done the root composer autoloader should include the plugin's autoloader as well. Not positive on this on though.
Well, I need to write in readme that a user must to include in her composer.json from my composer.json some packages for my library, right?
Run the composer commands inside the plugin directory.
The load order will see the "core" composer is loaded first, then the plugins composers are loaded second. This means, a plugin cannot override a core composer package, it can only introduce new ones. This logic is handled by the ComposerManager class.
As a side note: When a plugin is published to the October website, the server will build the composer file so you don't need to publish the /vendor folder if you plan to distribute a plugin.
@daftspunk thanks! Maybe it would be better if it was in documentation?
I installed OctoberCMS today, and installed this plugin through the Plugin Installer in the backend of my OctoberCMS install.
http://octobercms.com/plugin/anandpatel-wysiwygeditors
It has two dependencies listed in its composer.json file. Unfortunately, these dependencies do not appear to have been downloaded during the installation of this plugin. How can I correct this issue? Nothing is loading after installing the plugin, and the artisan command is refusing to run.
I should specify that I did not have composer installed on the system running OctoberCMS when I tried to install the plugin. Could this be why it went wrong?
Feel free to submit a PR to the docs.
Sorry to resurrect this issue, but this is a serious issue when deploying a plugin added to a versioning system, it will break the site. If you just execute artisan october:up the dependencies of the plugin specified in its composer.json file are not installed.
It would be cool if october:up command would execute composer install in case there's no vendor folder in the plugin dir and in case you provide an option like --composer-install.
I don't there is any expectation that october:up should run composer commands, this is a migration function. Some of our users do not use composer at all so it makes sense to keep these functions abstract. You should run the commands in this order:
composer installoctober:upYes, in the main project there's no issue with running composer install but for the plugins you can't know if it needs to be executed until the site stops working and you have to guess or remember which plugin needs it. For instance, I had this issue with the Twig extensions plugin the other day. I didn't notice it has a composer.json file and I updated on the server and it crashed.
This is fixed in the develop branch with the "composer-merge-plugin" package, see: https://github.com/octobercms/october/blob/develop/composer.json#L57-L65
This is nice. So can I update my current install without any issue, just add "wikimedia/composer-merge-plugin": "dev-master" and the config section ?
That's right! Then all plugin's composer files will be merged in to the main one automagically :smile:
How are conflicts handled?
I could be wrong but I assume "replace": false, suggests that packages introduced by plugins are directed not to _replace_ those found in the core packages. This is the logic implemented by October today when a plugin has been composer install'd inside its own directory, a plugin cannot override a core package.
Unfortunately is not working for my existing project. Modified my composer.json for a project started from master archive and I get this pretty message:
Problem 1
- october/rain 1.0.x-dev requires league/csv ~7.0 -> satisfiable by league/csv[7.0.0, 7.0.1, 7.1.0, 7.1.1, 7.1.2, 7.2.0] but these conflict with your requirements or minimum-stability.
- october/rain 1.0.x-dev requires league/csv ~7.0 -> satisfiable by league/csv[7.0.0, 7.0.1, 7.1.0, 7.1.1, 7.1.2, 7.2.0] but these conflict with your requirements or minimum-stability.
- Installation request for october/rain ~1.0 -> satisfiable by october/rain[1.0.x-dev].
Updated my project to latest October version. But when executing composer update there is a problem with some plugins that require specific versions for dependencies.
For instance, the plugin https://github.com/vojtasvoboda/oc-twigextensions-plugin requires symfony/translation:^3.0 but laravel 5.1.* needs 2.7, which creates a conflict. Any idea if and how this can be fixed ?
@cdarken @daftspunk I am having the same problem. Two plugins require specific versions of dependencies which leads to major conflicts because of a bug in the older version of said dependency. Would be great to have insights on how to solve this problem. Any solutions?
Unfortunately there is no solution to this issue. PHP cannot load two separate versions of the same library, I'm unaware of any language that can do this. The official advice is to use the latest version where possible, so contact the plugin author and ask them to update the library version and make reference the the plugin that uses the newer version.
As a side note, if October's dependencies are the problem, we will be updating to Laravel 5.5 LTS when that is released.
Most helpful comment
Run the composer commands inside the plugin directory.
The load order will see the "core" composer is loaded first, then the plugins composers are loaded second. This means, a plugin cannot override a core composer package, it can only introduce new ones. This logic is handled by the ComposerManager class.
As a side note: When a plugin is published to the October website, the server will build the composer file so you don't need to publish the /vendor folder if you plan to distribute a plugin.