I need to change Acorn path folder.
I have read docs and found out two ways to do that:
- Use ACORN_BASEPATH
- Use filters.
Default path is /app/web/app/cache/
for storage and bootstrap.
I have tried to define define('ACORN_BASEPATH', getenv('ACORN_BASEPATH') ?: '/app/uploads/cache');
, but it doesn’t have effect. Same for filters which I have added directly to function.php
apply_filters('acorn/paths', [
'storage' => 'web/app/uploads/cache'
]);
After unsuccessfully trying, I have started to debug Bootloader.php.
In the first step, is everything okay. Bootloader gets the right path.
// @codeCoverageIgnoreStart
if (defined('ACORN_BASEPATH')) {
return $this->basePath = rtrim(constant('ACORN_BASEPATH'), '/\\');
}
Even in the function findPath
we have a right path in variable $searchPaths
, but at return collect($searchPaths)
fires fallbackPath
.
As a result, I still have the default paths.
What I did wrong?
2 Likes
Does anybody have the experience of how to do that?
I found out what path should be absolute.
I mean should be ACORN_BASEPATH="/app/web/app/uploads/cache"
, but not ACORN_BASEPATH=“/web/app/uploads/cache”.
In that case, acorn Bootloader doesn’t use fallback paths but fails after and still generates files at app/cache/acorn
Fatal error: Uncaught RuntimeException: Unable to detect application namespace. in /app/vendor/roots/acorn/src/Roots/Acorn/Application.php:425 Stack trace: #0 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(315): Roots\Acorn\Application->getNamespace() #1 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(267): Illuminate\View\Compilers\ComponentTagCompiler->guessClassName('alert') #2 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(211): Illuminate\View\Compilers\ComponentTagCompiler->componentClass('alert') #3 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(144): Illuminate\View\Compilers\ComponentTagCompiler->componentString('alert', Array) #4 [internal function]: Illuminate\View\Compilers\ComponentTagCompiler->Illuminate\View\Compilers\{closure}(Array) #5 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(139): preg_replace_callback('/\n <...', Object(Closure), '@extends('layou...') #6 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(90): Illuminate\View\Compilers\ComponentTagCompiler->compileOpeningTags('@extends('layou...') #7 /app/vendor/illuminate/view/Compilers/ComponentTagCompiler.php(76): Illuminate\View\Compilers\ComponentTagCompiler->compileTags('@extends('layou...') #8 /app/vendor/illuminate/view/Compilers/BladeCompiler.php(407): Illuminate\View\Compilers\ComponentTagCompiler->compile('@extends('layou...') #9 /app/vendor/illuminate/view/Compilers/BladeCompiler.php(240): Illuminate\View\Compilers\BladeCompiler->compileComponentTags('@extends('layou...') #10 /app/vendor/illuminate/view/Compilers/BladeCompiler.php(159): Illuminate\View\Compilers\BladeCompiler->compileString('@extends('layou...') #11 /app/vendor/illuminate/view/Engines/CompilerEngine.php(55): Illuminate\View\Compilers\BladeCompiler->compile('/app/web/app/th...') #12 /app/vendor/illuminate/view/View.php(139): Illuminate\View\Engines\CompilerEngine->get('/app/web/app/th...', Array) #13 /app/vendor/illuminate/view/View.php(122): Illuminate\View\View->getContents() #14 /app/vendor/illuminate/view/View.php(91): Illuminate\View\View->renderContents() #15 /app/web/app/themes/pai/index.php(14): Illuminate\View\View->render() #16 /app/web/core/wp-includes/template-loader.php(106): include('/app/web/app/th...') #17 /app/web/core/wp-blog-header.php(19): require_once('/app/web/core/w...') #18 /app/web/index.php(6): require('/app/web/core/w...') #19 {main} thrown in /app/vendor/roots/acorn/src/Roots/Acorn/Application.php on line 425
Add in composer.json these lines:
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
Add in wp-config.php:
if ( ! defined( 'ACORN_BASEPATH' ) ) {
define( 'ACORN_BASEPATH', __DIR__ . '/absolute-path-to-plugin-dir );
}