├── .gitignore ├── composer.json ├── sample-plugins-composer.json ├── wordpress-composer-installer.php └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /composer.lock 3 | /plugins-composer.json 4 | /plugins-composer.lock 5 | /.idea/ 6 | /vendor/ -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coenjacobs/wordpress-composer-installer", 3 | "authors": [ 4 | { 5 | "name": "Coen Jacobs", 6 | "email": "coenjacobs@gmail.com" 7 | } 8 | ], 9 | "require": { 10 | "composer/composer": "dev-master", 11 | "wikimedia/composer-merge-plugin": "dev-master" 12 | } 13 | } -------------------------------------------------------------------------------- /sample-plugins-composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "wikimedia/composer-merge-plugin": "dev-master" 4 | }, 5 | "extra": { 6 | "merge-plugin": { 7 | "include": [ 8 | "composer.json", 9 | "../plugin-1/composer.json", 10 | "../plugin-2/composer.json" 11 | ] 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /wordpress-composer-installer.php: -------------------------------------------------------------------------------- 1 | 'install', 29 | '-d' => dirname( __FILE__ ), 30 | '--no-dev' => true, 31 | '--prefer-dist' => true, 32 | ) ); 33 | 34 | $output = null; //new Symfony\Component\Console\Output\StreamOutput(fopen('php://output','w')); 35 | $app = new Composer\Console\Application(); 36 | $app->setAutoExit(false); 37 | $app->run($input,$output); 38 | } 39 | 40 | add_filter( 'plugin_action_links', 'wpci_plugin_action_links', 10, 4 ); 41 | 42 | function wpci_plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) { 43 | if ( strstr( $plugin_file, 'wordpress-composer-installer.php' ) ) { 44 | $composer_link = wp_nonce_url( 'plugins.php?action=composer_install', 'composer_install_plugin' ); 45 | $actions['composer'] = 'Composer install'; 46 | } 47 | return $actions; 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress Composer Installer 2 | **Note:** This is extremely work in progress. Do not attempt to run any of this in production environment, unless you are the adventurous type. :) 3 | 4 | ## Install and usage 5 | 1. Install dependencies of this plugin first, by running `composer install`. 6 | 2. Activate the plugin in your WordPress install. 7 | 3. Copy the `sample-plugins-composer.json` file and rename it to `plugins-composer.json`. Add paths to the `composer.json` files you want to install the dependencies of. (This step will be automated in [#3](https://github.com/coenjacobs/wordpress-composer-installer/issues/3)). 8 | 4. Click on the `Composer install` plugin action link in the Plugins screen. This will install the dependencies required for merging the `composer.json` files. 9 | 5. Delete the now generated `plugins-composer.lock` file (This step will be automated in [#2](https://github.com/coenjacobs/wordpress-composer-installer/issues/2)). 10 | 6. Click on the `Composer install` plugin action link again, in the Plugins screen. This will install the dependencies of the plugins specified in the `plugins-composer.json` file. 11 | 7. The dependencies will now be installed in the `wp-content/vendor/` directory. You can include the autoloader at `wp-content/vendor/autoload.php`. 12 | 13 | ## Important bits during development 14 | - Process is really expensive and takes a long time. Probably need to put some kind of wizard, progress bar or whatever and make sure it doesn't time out. 15 | - Of course the plugin needs to be structured properly, this is only a proof of concept for now. 16 | - It needs to hook in on plugin activate/deactivate and do its magic there. Manual option to override. 17 | - Ryan McCue has provided a ton of great UI/UX things to look after in code like this: "[How I Would Solve Plugin Dependencies](http://journal.rmccue.io/322/plugin-dependencies/)" 18 | --------------------------------------------------------------------------------