A project set up by hand, as the installer would do it; it also covers PostgreSQL. The quick start is on Install yf.
Jump to Get yf Layout Database config SQLite Front controllers First admin Redis or Valkey
Composer: require the package from Packagist.
composer require yfix/yfvendor/autoload.php defines YF_PATH (the package directory). The package leaves .dev/ out, so the installer and this docs and demo site need a git checkout.
Git submodule: keep the framework as a submodule (or a plain checkout) next to the project code.
git submodule add https://github.com/yfix/yf.git yf
git submodule update --initThe front controllers then define YF_PATH themselves: define('YF_PATH', dirname(__DIR__) . '/yf/');
myproject/
config/
db_setup.php DB constants (read by yf)
project_conf.php $CONF, $PROJECT_CONF
www/ document root
index.php user front controller
admin/index.php admin front controller
uploads/ writable
modules/ admin_modules/ classes/
models/ plugins/ your code, overrides
templates/user/ templates/admin/
storage/ writable (logs in storage/logs/)
vendor/ composer (or yf/)A class or template in the project with the framework's name overrides it; site__ / adm__ classes extend it.
Bootstrap 5, as the installer sets it up: $CONF['css_framework'] = 'bs5'; in config/project_conf.php (without it, Bootstrap 3).
The database constants yf reads. DB_TYPE is mysqli (MySQL / MariaDB) or pgsql (PostgreSQL):
<?php
define('DB_TYPE', 'mysqli'); // or pgsql
define('DB_HOST', 'localhost');
define('DB_NAME', 'myproject');
define('DB_USER', 'myproject');
define('DB_PSWD', 'secret');
define('DB_PREFIX', 't_');
define('DB_CHARSET', 'utf8mb4');One file, outside the web root:
<?php
define('DB_TYPE', 'sqlite');
// one file, outside the web root: yf refuses a database under www/
define('DB_NAME', dirname(__DIR__) . '/storage/db/site.sqlite');
define('DB_PREFIX', 't_');The directory must exist and be writable by PHP (SQLite keeps -wal / -shm files next to the database).
yf turns on foreign keys and WAL, compares text case-insensitively like MySQL (COLLATE NOCASE, ASCII only),
and rebuilds a table for the ALTER TABLE changes SQLite lacks. No stored procedures, events, database users or
FULLTEXT indexes (the db_fulltext search falls back to LIKE).
LIKE and NOCASE columns treat A and a alike, but not Я and я or
É and é: Cyrillic, Greek and accented text matches case-sensitively, unlike MySQL's utf8mb4_general_ci.
Also unlike MySQL: CONCAT() skips NULL arguments instead of returning NULL, and FIND_IN_SET() is case-sensitive.www/index.php, the user side:
<?php
require dirname(__DIR__) . '/vendor/autoload.php'; // defines YF_PATH
// defined('YF_PATH') || define('YF_PATH', dirname(__DIR__) . '/yf/'); // submodule instead
define('PROJECT_PATH', __DIR__ . '/');
defined('DEBUG_MODE') || define('DEBUG_MODE', false); // .dev/override.php may set it first
require dirname(__DIR__) . '/config/project_conf.php';
$PROJECT_CONF['tpl']['REWRITE_MODE'] = true; // /object/action/id URLs
require YF_PATH . 'classes/yf_main.class.php';
new yf_main('user', $no_db_connect = false, $auto_init_all = true);www/admin/index.php, the admin:
<?php
require dirname(__DIR__, 2) . '/vendor/autoload.php';
define('PROJECT_PATH', dirname(__DIR__) . '/');
defined('DEBUG_MODE') || define('DEBUG_MODE', false); // .dev/override.php may set it first
require dirname(__DIR__, 2) . '/config/project_conf.php';
require YF_PATH . 'classes/yf_main.class.php';
new yf_main('admin', $no_db_connect = false, $auto_init_all = true);Create an empty database. yf creates its system tables on first use ($PROJECT_CONF['db']['FIX_DATA_SAFE'], on by default).
Open /admin/ once so that sys_admin exists, then add the first administrator with a bcrypt hash:
php -r 'echo password_hash("change-me", PASSWORD_BCRYPT), PHP_EOL;'
mysql myproject -e "INSERT INTO t_sys_admin (login, password, email, \`group\`, active, add_date)
VALUES ('admin', '<the hash>', '[email protected]', 1, '1', UNIX_TIMESTAMP())"redis() reads REDIS_* names (constant, $CONF or environment); valkey() and the valkey drivers read VALKEY_* and fall back to REDIS_*.
User, password and TLS settings come from the environment only as VALKEY_*, or as REDIS_* with $PROJECT_CONF['wrapper_redis']['CREDENTIALS_FROM_ENV'] = true.
Both speak to Redis 6+ and Valkey through phpredis (or predis). TLS checks the server certificate unless REDIS_TLS_VERIFY_PEER is off.
define('VALKEY_HOST', 'valkey.internal'); // or REDIS_HOST: both drivers fall back to it
define('VALKEY_PORT', 6380);
define('VALKEY_USER', 'app'); // ACL user, with the password
define('VALKEY_PASSWORD', getenv('VALKEY_PASSWORD'));
define('VALKEY_TLS', true); // or a tls:// host
define('VALKEY_TLS_CA_FILE', '/etc/ssl/valkey-ca.pem');
$PROJECT_CONF['cache']['DRIVER'] = 'valkey'; // or 'redis'
$PROJECT_CONF['wrapper_queue']['driver'] = 'valkey';
$PROJECT_CONF['wrapper_pubsub']['driver'] = 'valkey';
// sessions: php.ini session.save_handler = redis, session.save_path = "tls://valkey.internal:6380?auth[]=app&auth[]=..."