bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

Custom views folder #1199

Closed charles1e62 closed 3 years ago

charles1e62 commented 3 years ago

How to configure the views directory in a project with the following structure.

app
- public
    index.php
- src
    - lib
    - views
        home.htm
    bootstrap.php
    config.ini
    routes.php

Index.php

require '../src/bootstrap.php';

config.ini

[globals]

DEBUG=3
UI=views/

bootstrap.php

$f3=require('lib/base.php');

$f3->set('DEBUG',3);

if ((float)PCRE_VERSION<8.0)
    trigger_error('PCRE version is out of date');

// Load configuration
$f3->config('config.ini');

require 'routes.php';

$f3->run();

routes.php

$f3->route('GET /',
    function($f3) {
        echo View::instance()->render('home.htm');
    }
);

Request works correctly but the view is not rendered.