Closed bruno-barros closed 9 years ago
Hi @bruno-barros
There are 2 problems, the name you have to put in composer.json
is not the GitHub repository name, but name that is set in composer.json
for the repo.
After that, I guess that you want to use your fork, not the original plugin repo. I guess that because I read in the error message: "The requested package bruno-barros/cortex-plugin ..."
If you want to use your fork you need to specify the repositories
setting in composer.json
(see docs) and not to change package name (unless you change it in your fork).
So, your composer.json
should be something like:
"require": {
"php": ">=5.4",
"brain/cortex-plugin": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/bruno-barros/Cortex-Plugin"
}
],
"minimum-stability" : "dev",
"prefer-stable": true
Regarding introducing a tag version, that's planned, but as long as you use
"minimum-stability" : "dev",
"prefer-stable": true
it should work with any issue.
Yeah. Now I'm able to install the plugin. I configured the composer.json to install the plugin on mu-plugin
folder, but the Brain\Cortex::boot();
is not booting the modules anymore.
In the docs I see it must be just after the autoload.php
, but on my case, the autoload.php
is required before the Wordpress bootstrap.
# wp-config.php
require_once('src/config' . DS . 'start.php');
require_once(ABSPATH.'wp-settings.php');
# src/config/start.php
require_once 'vendor/autoload.php';
Doesn't matter where I call Brain\Cortex::boot();
. It isn't booting.
So, should I keep Brain modules on it own vendor folder to require and booting, or can I do it in this scenario?
Yep, all Brain modules are intended to be used in WordPress context.
If you load Composer autoload before loading WP environment you are trying to load Brain modules before WordPress is available and it will not work as expected.
However, I think that load all Brain modules manually should work.
You need to create a mu-plugin that contain something like:
<?php
add_action( 'brain_init', function( $brain ) {
$brain->addModule( new Brain\Amygdala\BrainModule );
$brain->addModule( new Brain\Striatum\BrainModule );
$brain->addModule( new Brain\Cortex\BrainModule );
} );
add_action( 'after_setup_theme', function() {
Brain\Container::boot( new \Pimple\Container );
}, 0 );
Save this file and put in mu-plugin folder.
After that, be sure that WordPress does not load Cortex as a mu plugin, because all the loading is done by this file, so you only need that proper classes are available, and that is assured by the Composer autoload.
In facts, you don't need Cortex plugin, the Cortex package should be absolutely fine in your case, you can install it using "brain\cortex": "dev-master"
instead of "brain\cortex-plugin": "dev-master"
.
Man, thank you. It was exactly what I needed.
Hi Giuseppe. A few days ago we talked about an issue I had and you said that it would be because of the minimum stability version. At that time I installed Cortex plugin running composer in its own directory... and it works, but it is not the best solution because I need to run composer on my root project and where the Cortex plugin is. So, if I try this on my composer:
I got the message:
I really do not have a answer, but maybe you could promote a tag version to all the projects to avoid dev-master.