Getting Started
Føhn is a modern WordPress framework powered by Tempest Framework. It brings attribute-based auto-discovery to WordPress development, eliminating boilerplate code for hooks, post types, blocks, and more.
Why Føhn?
Traditional WordPress development requires manually registering every hook, post type, and block. It also lacks modern OOP practices like dependency injection and autowiring. Føhn changes this with PHP 8 attributes and a powerful DI container:
Before (Traditional WordPress):
php
// functions.php - scattered registrations
add_action('init', function () {
register_post_type('product', [
'public' => true,
'label' => 'Products',
'has_archive' => true,
// ... 20 more lines
]);
});
add_action('after_setup_theme', function () {
add_theme_support('post-thumbnails');
});
add_filter('excerpt_length', fn () => 30);After (Føhn):
php
// app/Models/Product.php
#[AsPostType(name: 'product', singular: 'Product', plural: 'Products', hasArchive: true)]
final class Product extends Post {}
// app/Hooks/ThemeHooks.php
final class ThemeHooks
{
// Dependencies are autowired
public function __construct(
private readonly MyService $service,
) {}
#[AsAction('after_setup_theme')]
public function setupTheme(): void
{
add_theme_support('post-thumbnails');
}
#[AsFilter('excerpt_length')]
public function excerptLength(): int
{
return 30;
}
}Features
- Hooks —
#[AsAction]and#[AsFilter]for WordPress hooks - Post Types —
#[AsPostType]with Timber integration and fluent queries - Taxonomies —
#[AsTaxonomy]with hierarchical support - Views —
#[AsContextProvider]and#[AsTemplateController] - ACF —
#[AsAcfBlock],#[AsAcfFieldGroup]and#[AsAcfOptionsPage], from the separatestudiometa/foehn-acfpackage - Native Blocks —
#[AsBlock]with Interactivity API support - Block Patterns —
#[AsBlockPattern]with Twig templates - REST API —
#[AsRestRoute]for custom endpoints - Shortcodes —
#[AsShortcode]for shortcode handlers - Caching — Injectable PSR-16
CacheInterfacewith tagged cache support - CLI —
#[AsCliCommand]for WP-CLI commands - Seeders —
#[AsSeeder]classes that write sample content withwp foehn seed - Page cache — static HTML pages that nginx or Apache serves, with
PageCacheConfig - Debugging —
wp foehn inspect,errors,logandtraceshow what the project declares and what a request ran
Requirements
- PHP 8.5+
- WordPress 6.4+
- Composer
Next Steps
- New project? Start with the Starter Theme — a working WordPress theme in minutes, with nothing in it you have to delete
- Want to see everything first? Read the Demo Project — one worked example of every attribute, and the theme the end-to-end tests run against
- Existing theme? Follow the Manual Installation guide
- Learn about Hooks, Post Types, and Query Posts
- Build ACF Blocks with Arrayable DTOs