roots / sage

WordPress starter theme with Laravel Blade components and templates, Tailwind CSS, and a modern development workflow
https://roots.io/sage/
MIT License
12.76k stars 3.06k forks source link

Class 'App' not found when moving composer.json #2094

Closed OwenMelbz closed 6 years ago

OwenMelbz commented 6 years ago

Submit a feature request or bug report


What is the current behavior?

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

What is the expected or desired behavior?

When moved the class should still be locatable and work as expected


Bug report

Please provide steps to reproduce, including full log output:

As mentioned above ^^

Please describe your local environment:

WordPress version: 4.9.8

OS: macos 10.13.6

NPM/Node version: 6.1.0

Where did the bug happen? Development or remote servers?

Both

Is there a related Discourse thread or were any utilized (please link them)?

No


retlehs commented 6 years ago

Is there a related Discourse thread or were any utilized (please link them)?

No

there is :)

rather than making 3 separate github issues, please head over to roots discourse where this has already been discussed