A modern WordPress theme framework built with Laravel components, designed for developers who want to build powerful WordPress themes with a clean, object-oriented architecture.
- Laravel Integration: Leverages popular Laravel components (Container, Validation, Pagination, View, etc.)
- ACF Support: Seamless integration with Advanced Custom Fields via Corcel
- Flexible Routing: Custom routing system with FastRoute integration
- Module System: Organized module-based architecture for theme components
- Template Hierarchy: Brain Hierarchy integration for intelligent template loading
- WordPress REST API: Easy API endpoint creation
- Debugging: Tracy integration for advanced debugging
- Scaffolding: Generate modules, templates, and components with CLI tools
- PHP: 8.2 or higher
- WordPress: 5.0 or higher
- Composer: 2.0 or higher
composer create-project sixmonkey/sloth my-theme- Clone or download this repository into your WordPress theme directory
- Run
composer installto install dependencies - Configure your theme as needed
Activate the theme in your WordPress admin panel. The framework will automatically bootstrap and register all service providers.
Use the scaffolder to create a new module:
php sloth-cli.php make:module MyModuleThis creates:
src/Module/MyModule/src/Module/MyModule/Module.phpsrc/_view/Module/my-module/- SCSS files and ACF configuration
Create a routes.php file in your theme root:
<?php
use Sloth\Facades\Route;
// Basic route
Route::get('/about', [
'controller' => 'PageController',
'action' => 'about',
]);
// With parameters
Route::get('/blog/{slug}', [
'controller' => 'BlogController',
'action' => 'show',
]);Controllers go in Theme/Controller/:
<?php
namespace Theme\Controller;
use Sloth\Controller\Controller;
class PageController extends Controller
{
public function about(): void
{
$this->view('about', [
'title' => 'About Us',
]);
}
}<?php
use Sloth\Model\Post;
// Get a post by ID
$post = Post::find(123);
// Get posts by category
$posts = Post::where('category', 'news')
->orderBy('date', 'DESC')
->limit(10)
->get();
// Custom post type
$projects = \Sloth\Model\Post::type('project')
->status('publish')
->get();<?php
use Sloth\Facades\View;
// Render a view
View::make('partials.header', ['title' => 'Welcome']);
// With layout
View::make('content.page')
->layout('layouts.main')
->with(['title' => 'Page Title']);<?php
use Sloth\Facades\Validation;
$validator = Validation::make($request->all(), [
'name' => 'required|min:3|max:255',
'email' => 'required|email',
'url' => 'url|nullable',
]);
if ($validator->fails()) {
$errors = $validator->errors();
}Create a .env file in your theme root:
APP_ENV=local
WP_DEBUG=true
DATABASE_HOST=localhost
DATABASE_NAME=wordpress
DATABASE_USER=root
DATABASE_PASSWORD=Add configuration files in src/config/:
<?php
return [
'setting_name' => 'value',
'another_setting' => true,
];Access configuration via:
<?php
use Sloth\Facades\Configure;
$value = Configure::get('config_file.setting_name');sloth/
├── src/
│ ├── Core/ # Core framework classes
│ ├── Model/ # WordPress model extensions
│ ├── Route/ # Routing system
│ ├── View/ # View system
│ ├── Controller/ # Base controllers
│ ├── Facades/ # Facade classes
│ ├── Module/ # Module system
│ ├── Field/ # Custom ACF fields
│ ├── _view/ # Twig templates
│ └── config/ # Configuration files
├── tests/ # PHPUnit tests
├── docs/ # Additional documentation
├── composer.json # Dependencies
└── phpunit.xml # Test configuration
| Facade | Description |
|---|---|
Route |
Routing system |
View |
Template rendering |
Validation |
Form validation |
Configure |
Configuration access |
Pagination |
Pagination helper |
Module |
Module management |
Menu |
Menu system |
Customizer |
WordPress Customizer |
Deployment |
Deployment helpers |
Layotter |
Page builder |
# Create a new module
php sloth-cli.php make:module ModuleName
# Install the theme
php sloth-cli.php install
# Generate documentation
composer run docscomposer testcomposer analyse# Check code style
composer cs-check
# Auto-fix code style
composer cs-fixcomposer docsContributions are welcome! Please see CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.