Code Monkey home page Code Monkey logo

Comments (4)

gmazzap avatar gmazzap commented on August 11, 2024

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.

from cortex.

bruno-barros avatar bruno-barros commented on August 11, 2024

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?

from cortex.

gmazzap avatar gmazzap commented on August 11, 2024

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".

from cortex.

bruno-barros avatar bruno-barros commented on August 11, 2024

Man, thank you.
It was exactly what I needed.

from cortex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.