leafMVC
leafMVC copied to clipboard
Error when using BareUI: `Call to undefined method Leaf\BareUI::configure()`
I try to get this running with BareUi instead of Blade templates. What I did was
- scaffolding leaf mvc with the cli
- remove
leafs/blade
and installleafs/bareui
- in
public/index.php
replaceLeaf\View::attach(\Leaf\Blade::class)
withLeaf\View::attach(\Leaf\BareUI::class)
- in
config/view.php
set'viewEngine' => \Leaf\BareUI::class
and replaceView::blade()->configure($config['views'], $config['cache'])
withLeaf\BareUI::config("path", $config['views'])
But I get the following error:
Error thrown with message "Call to undefined method Leaf\BareUI::configure()"
Stacktrace:
#10 Error in <my-project>/vendor/leafs/mvc-core/src/globals/functions.php:43
#9 view in <my-project>/vendor/leafs/mvc-core/src/globals/functions.php:63
#8 render in <my-project>/app/routes/_app.php:7
#7 Leaf\Core:{closure} in <my-project>/vendor/leafs/router/src/Router/Core.php:531
#6 call_user_func_array in <my-project>/vendor/leafs/router/src/Router/Core.php:531
#5 Leaf\Router\Core:invoke in <my-project>/vendor/leafs/router/src/Router/Core.php:521
#4 Leaf\Router\Core:handle in <my-project>/vendor/leafs/router/src/Router/Core.php:466
#3 Leaf\Router\Core:run in <my-project>/vendor/leafs/leaf/src/App.php:382
#2 Leaf\App:run in <my-project>/vendor/leafs/mvc-core/src/Core.php:121
#1 Leaf\Core:runApplication in <my-project>/public/index.php:110
#0 require_once in <my-project>/index.php:28
Am I doing something wrong and the mvc requires more config to change the view engine?
This is fixed when changing configure()
to config()
in /mvc-core/src/globals/functions.php
, so I guess BladeUi should also impement configure()
?
Hi @arnoson sorry about this, it seems our documentation did not completely cover the steps to switch to bareui. You will need to swap out your config/view.php
with this config:
<?php
use Leaf\View;
return [
/*
|--------------------------------------------------------------------------
| Template Engine [EXPERIMENTAL]
|--------------------------------------------------------------------------
|
| Leaf MVC unlike other frameworks tries to give you as much control as
| you need. As such, you can decide which view engine to use.
|
*/
'viewEngine' => \Leaf\BareUI::class,
/*
|--------------------------------------------------------------------------
| Custom config method
|--------------------------------------------------------------------------
|
| Configuration for your templating engine.
|
*/
'config' => function ($config) {
View::bareui()->config($config['views']);
},
/*
|--------------------------------------------------------------------------
| Custom render method
|--------------------------------------------------------------------------
|
| This render method is triggered whenever render() is called
| in your app if you're using a custom view engine.
|
*/
'render' => function ($view, $data = []) {
return View::bareui()->render($view, $data);
},
];
This will teach Leaf how to work with BareUI or ant templating engine of your choice.
Great, thanks for the quick reply!