Moving sage composer.json to the root

Hi - I’m aware some of you like to have the separation of a theme composer.json and a plugins composer.json - however for a variety of reasons we just want to have it in the same root one.

I’ve set up a normal bedrock and sage install to start with that works and activates etc.

Then I start to move the dependencies into the root file by moving…

"roots/sage-lib": "~9.0.1",
"soberwp/controller": "~9.0.0-beta.4"

to the root composer.json - I then move the PSR-4 mapping so it resembles

"autoload": {
    "psr-4": {
      "App\\": "web/app/themes/sage/app"
    }
  },

then run composer update and for extra piece of mind composer du

The install goes fine - clear the blade cache just incase and refresh. However it then throws this error


Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App' not found in /Users/owen/Sites/bedrock/web/app/uploads/cache/8bf0f00af53fe2654545f792466d0b5c5e716614.php:2 Stack trace: #0 /Users/owen/Sites/bedrock/vendor/illuminate/view/Engines/PhpEngine.php(43): include() #1 /Users/owen/Sites/bedrock/vendor/illuminate/view/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/Users/owen/Sit...', Array) #2 /Users/owen/Sites/bedrock/vendor/illuminate/view/View.php(142): Illuminate\View\Engines\CompilerEngine->get('/Users/owen/Sit...', Array) #3 /Users/owen/Sites/bedrock/vendor/illuminate/view/View.php(125): Illuminate\View\View->getContents() #4 /Users/owen/Sites/bedrock/vendor/illuminate/view/View.php(90): Illuminate\View\View->renderContents() #5 /Users/owen/Sites/bedrock/web/app/uploads/cache/3679ea20f9f1d3f1e5da4f14237a149a92ed3790.php(2): Illuminate\View\View->render() #6 /Users/owen/Sites/bedrock/vendor/illuminate/view/Engines/PhpEngine.php(43): include('/Users/owe in /Users/owen/Sites/bedrock/web/app/uploads/cache/8bf0f00af53fe2654545f792466d0b5c5e716614.php on line 2

It comes across like it’s not autoloading things correctly.

Below are the main configs from the composer.json

{
    "config": {
        "preferred-install": "dist"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://wpackagist.org"
        }
    ],
    "require": {
        "php": ">=7.0",
        "composer/installers": "^1.4",
        "vlucas/phpdotenv": "^2.0.1",
        "johnpbloch/wordpress": "4.*",
        "oscarotero/env": "^1.1.0",
        "roots/wp-password-bcrypt": "1.0.0",
        "roots/sage-lib": "~9.0.1",
        "soberwp/controller": "~9.0.0-beta.4"
    },
    "extra": {
        "installer-paths": {
            "web/app/mu-plugins/{$name}/": [
                "type:wordpress-muplugin"
            ],
            "web/app/plugins/{$name}/": [
                "type:wordpress-plugin"
            ],
            "web/app/themes/{$name}/": [
                "type:wordpress-theme"
            ]
        },
        "wordpress-install-dir": "web/wp"
    },
    "autoload": {
        "psr-4": {
            "App\\": "web/app/themes/sage/app"
        }
    }
}

– Are you guys able to see whats going wrong? or able to provide some information how to hook this up properly?

Thanks

Missing illuminate/support?

@TangRufus

All the laravel packages require it anyway so didn’t bother explicitly defining it.

Without defining it still works you can see the pages it installed

brain/hierarchy                                   2.3.1        No-dependencies package that embodies WordPress template hierarchy
composer/installers                               v1.5.0       A multi-framework Composer library installer
doctrine/inflector                                v1.3.0       Common String Manipulations with regard to casing and singular/plural rules.
hassankhan/config                                 0.10.0       Lightweight configuration file loader that supports PHP, INI, XML, JSON, and...
illuminate/config                                 v5.6.33      The Illuminate Config package.
illuminate/container                              v5.6.33      The Illuminate Container package.
illuminate/contracts                              v5.6.33      The Illuminate Contracts package.
illuminate/events                                 v5.6.33      The Illuminate Events package.
illuminate/filesystem                             v5.6.33      The Illuminate Filesystem package.
illuminate/support                                v5.6.33      The Illuminate Support package.
illuminate/view                                   v5.6.33      The Illuminate View package.
johnpbloch/wordpress                              4.9.8        WordPress is web software you can use to create a beautiful website or blog.
johnpbloch/wordpress-core                         4.9.8        WordPress is web software you can use to create a beautiful website or blog.
johnpbloch/wordpress-core-installer               1.0.0.2      A custom installer to handle deploying WordPress with composer
nesbot/carbon                                     1.33.0       A simple API extension for DateTime.
oscarotero/env                                    v1.1.0       Simple library to consume environment variables
psr/container                                     1.0.0        Common Container Interface (PHP FIG PSR-11)
psr/log                                           1.0.2        Common interface for logging libraries
psr/simple-cache                                  1.0.1        Common interfaces for simple caching
roots/sage-lib                                    9.0.1        Library files for Sage Starter Theme
roots/wp-password-bcrypt                          1.0.0        WordPress plugin which replaces wp_hash_password and wp_check_password's php...
soberwp/controller                                9.0.0-beta.4 WordPress package to enable a basic controller when using Blade with Sage 9
symfony/debug                                     v4.1.3       Symfony Debug Component
symfony/finder                                    v4.1.3       Symfony Finder Component
symfony/polyfill-ctype                            v1.9.0       Symfony polyfill for ctype functions
symfony/polyfill-mbstring                         v1.9.0       Symfony polyfill for the Mbstring extension
symfony/translation                               v4.1.3       Symfony Translation Component
symfony/yaml                                      v3.4.14      Symfony Yaml Component
vlucas/phpdotenv                                  v2.5.1       Loads environment variables from '.env' to 'getenv()' '$_ENV' and '$_SERVER...

how about roots/sage-installer ?
(in require-dev)

Don’t do this. We won’t support it.