Custom Kirby Composer Setup

Hi,

I’ve a custom composer setup that I recently updated to Kirby 3.

 build/
 ⌙ kirby/
 ⌙ asset/
 ⌙ sites/
 ⌙ etc./
vendor/
composer.json

composer json:


    "require":{
        "getkirby/cms": "^3.0"
    },
    "extra": {
    "kirby-cms-path": "build/kirby",
    "kirby-plugin-path": "build/site/plugins"
    },
    "config": {
        "optimize-autoloader": true
    }

This worked fine till today; I realized after I installed a plugin that the plugin didn’t load it dependencies. Resetting everything I also realized that kirby doens’t find it dependencies anymore. Only if I run composer install in the kirby folder it works again but defeats the purpose as I do have mutliple vendor folders.

If you use a custom directory setup, Kirby can’t automatically find the vendor directory, which it generally expects next to its own kirby directory, see the bootstrap.php file.

The reason why it worked before and doesn’t anymore is that we have updated our Composer installer to delete the kirby/vendor directory after installation to avoid duplicated dependencies and autoloaders in Composer setups.

To fix this, you need to manually load the Composer autoloader in your index.php like this:

<?php

require <your path to vendor/autoload.php>;
require __DIR__ . '/kirby/bootstrap.php';

echo (new Kirby)->render();