Skip to content

A PHP framework to get your site up and running fast.

RobertGrubb/hoist-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hoist PHP Framework

A lightweight, modern PHP MVC framework designed for rapid development with zero configuration, interactive UI components, and production-ready features out of the box.

PHP Version License Framework Components

📚 Complete API Documentation

Hoist includes comprehensive API documentation for all framework components:

🎯 Command Line Interface

💾 Primary Storage System

  • FileDatabase API - Zero-configuration JSON database with SQL-like queries (default storage)

🧩 Component System (The Bread and Butter!)

  • Components API - Dynamic component system for reusable UI elements and modular architecture

🔗 Core Framework APIs

  • Authentication API - User authentication, sessions, and role-based access
  • Database API - MySQL and FileDatabase operations with query building
  • Model API - Active Record pattern with security features and validation
  • Request API - HTTP request handling, data validation, and file uploads
  • Response API - JSON responses, redirects, and content delivery
  • Router API - URL routing, parameter extraction, and nested controllers-Components-purple)

✨ What Makes Hoist Special?

Hoist isn't just another PHP framework - it's a complete development ecosystem that gets you from idea to production faster than ever before. With zero configuration setup, interactive UI components, and enterprise-grade security, Hoist eliminates the complexity while delivering professional results.

🚀 Start building in under 60 seconds
🎨 Beautiful UI components included
🔐 Security-first architecture
📦 Docker-ready deployment
🗂️ Flexible database options


🎯 Key Features

🎨 Interactive UI Component System

  • 30+ Pre-built Components: Forms, modals, tables, badges, cards, and more
  • Tailwind CSS Integration: Beautiful, responsive design out of the box
  • JavaScript Interactivity: Modal dialogs, confirmations, dynamic tables
  • Organized Architecture: Logical separation into Form/, UI/, and Layout/ components

🚀 Zero Configuration Development

  • Convention-based Routing: /users/createUsersController::create()
  • Automatic Component Loading: Render components with simple syntax
  • FileDatabase System: Start building without database setup
  • Docker Container: Single command deployment
  • 🎯 CLI Migration Tool: One-command FileDatabase → MySQL conversion

💫 Revolutionary Database Migration

The feature that changes everything! Hoist's CLI tool enables instant migration from development to production:

# 1. Develop with FileDatabase (0 setup time)
# Build your entire MVP with JSON-based storage

# 2. Scale to MySQL (1 command)
php hoist migrate:to-mysql --database=myapp

# 3. Production ready!
# Same code, production database

What the migration does:

  • Discovers all tables automatically from FileDatabase
  • Analyzes data types from existing records
  • Generates MySQL schemas with proper column types
  • Migrates all data preserving relationships
  • Zero downtime - works with live applications

This eliminates the development bottleneck:

  • No more "database setup before coding"
  • No more "different storage for dev vs prod"
  • No more complex migration scripts
  • Start coding immediately, scale when ready!

🏗️ Modern MVC Architecture

  • Service Injection: Clean dependency management throughout
  • Nested Controllers: Organize code in logical subdirectories
  • Flexible Models: Dual FileDatabase/MySQL support
  • Secure Views: Built-in XSS protection and validation

🛡️ Enterprise Security

  • Input Validation: 30+ validation rules with custom messages
  • XSS Protection: Automatic output escaping and cleaning
  • Authentication System: Role-based access with session management
  • CSRF Protection: Built-in security against cross-site attacks

📊 Production Features

  • Admin Panel: Complete user management interface
  • Caching System: Redis, Memcached, and file-based options
  • Error Handling: Graceful degradation with detailed debugging
  • RESTful APIs: JSON responses with proper HTTP status codes

🎮 Interactive Demo

Visit the live admin panel to see Hoist's capabilities:

  1. Start the application: docker-compose up -d
  2. Visit: http://localhost:8080
  3. Login as admin: Navigate to user authentication demo
  4. Explore admin panel: See interactive tables, modals, and confirmations

Admin Panel Features:

  • ✅ Interactive user management with modals
  • ✅ Dynamic data tables with action buttons
  • ✅ Confirmation dialogs for destructive actions
  • ✅ Real-time statistics and activity feeds
  • ✅ Role-based access control
  • ✅ Responsive design on all devices

🚀 Quick Start

One-Command Setup

git clone https://github.com/RobertGrubb/hoist-php.git
cd hoist-php
docker-compose up -d

That's it! Open http://localhost:8080 and start building.

🎯 GAME-CHANGING CLI Tool

Hoist includes a powerful CLI tool that revolutionizes the development-to-production workflow:

📚 Complete CLI Documentation →

⚡ Zero-to-Production Migration

The most innovative feature - seamlessly migrate from FileDatabase to MySQL:

# Start with FileDatabase (zero setup)
# Build your entire MVP with file-based storage

# When ready for production, ONE COMMAND:
php hoist migrate:to-mysql --database=myapp --user=root --password=secret

# ✅ Automatically converts ALL your data
# ✅ Generates proper MySQL schemas
# ✅ Preserves all relationships
# ✅ Zero downtime migration

This solves the classic development dilemma:

  • 🎯 Development: FileDatabase (instant setup, zero configuration)
  • 🚀 Production: MySQL (scalable, production-ready)
  • Migration: One command transition!

🛠️ Development Tools

# Generate code scaffolding
php hoist generate:controller UserController
php hoist generate:model User
php hoist generate:component Form.CustomInput

# Development server
php hoist serve --port=8080

# Clear cache
php hoist cache:clear

# See all commands
php hoist --help

📖 View Complete CLI Reference →

Your First Component

Create an interactive user interface in minutes:

// In any controller
$this->instance->view->render('dashboard', [
    'users' => $users
]);
<!-- In your view -->
<!-- Render a beautiful data table -->
<?= $components->render('Layout.DataTable', [
    'headers' => ['Name', 'Email', 'Status'],
    'rows' => array_map(function($user) {
        return [
            'data' => $user,
            'cells' => [
                htmlspecialchars($user['name']),
                htmlspecialchars($user['email']),
                $components->render('UI.Badge', [
                    'text' => $user['status'],
                    'color' => $user['status'] === 'active' ? 'green' : 'red'
                ])
            ]
        ];
    }, $users),
    'actions' => [
        [
            'icon' => 'fas fa-edit',
            'class' => 'text-blue-600 hover:text-blue-900',
            'title' => 'Edit',
            'onclick' => 'openModal(\'editUserModal\'); loadUser(\'{id}\')'
        ]
    ]
]) ?>

<!-- Add a modal dialog -->
<?= $components->render('UI.Modal', [
    'id' => 'editUserModal',
    'title' => 'Edit User',
    'content' => '<!-- Your form content -->'
]) ?>

🎨 UI Component Gallery

📝 Form Components

Create beautiful, accessible forms with zero custom CSS:

// Text input with validation styling
<?= $components->render('Form.Input', [
    'type' => 'email',
    'name' => 'email',
    'label' => 'Email Address',
    'placeholder' => 'Enter your email',
    'required' => true
]) ?>

// Select dropdown with options
<?= $components->render('Form.Select', [
    'name' => 'role',
    'label' => 'User Role',
    'options' => ['user' => 'User', 'admin' => 'Administrator'],
    'required' => true
]) ?>

// Styled button with icon
<?= $components->render('Form.Button', [
    'text' => 'Save Changes',
    'icon' => 'fas fa-save',
    'variant' => 'primary',
    'onclick' => 'handleSave()'
]) ?>

🎯 UI Components

Interactive elements that bring your interface to life:

// Status badges with colors
<?= $components->render('UI.Badge', [
    'text' => 'Active',
    'icon' => 'fas fa-check-circle',
    'color' => 'green'
]) ?>

// Information cards
<?= $components->render('UI.Card', [
    'title' => 'User Statistics',
    'content' => 'Your dashboard content here'
]) ?>

// Modal dialogs with JavaScript integration
<?= $components->render('UI.Modal', [
    'id' => 'confirmDialog',
    'title' => 'Confirm Action',
    'size' => 'lg',
    'content' => 'Modal content with forms or information'
]) ?>

// Confirmation dialogs
<?= $components->render('UI.Confirmation', [
    'id' => 'deleteConfirm',
    'title' => 'Delete Item',
    'message' => 'This action cannot be undone.',
    'variant' => 'danger',
    'confirmAction' => 'handleDelete()'
]) ?>

📊 Layout Components

Display data beautifully with built-in interactivity:

// Interactive data tables
<?= $components->render('Layout.DataTable', [
    'headers' => ['User', 'Email', 'Role', 'Actions'],
    'rows' => $userRows,
    'actions' => [
        ['icon' => 'fas fa-eye', 'onclick' => 'viewUser(\'{id}\')'],
        ['icon' => 'fas fa-edit', 'onclick' => 'editUser(\'{id}\')'],
        ['icon' => 'fas fa-trash', 'onclick' => 'deleteUser(\'{id}\')']
    ]
]) ?>

// Statistics cards
<?= $components->render('Layout.AdminStatCard', [
    'title' => 'Total Users',
    'value' => count($users),
    'icon' => 'fas fa-users',
    'color' => 'blue'
]) ?>

// Feature showcase cards
<?= $components->render('Layout.FeatureCard', [
    'title' => 'Zero Configuration',
    'description' => 'Start building immediately with smart defaults',
    'icon' => 'fas fa-rocket',
    'color' => 'blue'
]) ?>

🏗️ Architecture Excellence

📁 Organized Component Structure

Application/Components/
├── Form/                    # Input elements
│   ├── Input.php           # Text inputs, email, password
│   ├── Button.php          # Interactive buttons
│   ├── Select.php          # Dropdown selections
│   └── Checkbox.php        # Toggle inputs
├── UI/                     # Interface elements
│   ├── Modal.php           # Dialog windows
│   ├── Confirmation.php    # Action confirmations
│   ├── Badge.php           # Status indicators
│   ├── Card.php            # Content containers
│   └── Alert.php           # Notification messages
└── Layout/                 # Display components
    ├── DataTable.php       # Interactive tables
    ├── FeatureCard.php     # Feature showcases
    ├── AdminStatCard.php   # Dashboard statistics
    └── DefinitionList.php  # Key-value displays

🔧 Service-Driven Components

Every component follows the clean service injection pattern:

return function ($instance, $data = []) {
    // Access to all framework services
    $auth = $instance->auth;
    $request = $instance->request;
    $validation = $instance->validation;

    // Component logic with security and validation
    $content = htmlspecialchars($data['content'] ?? '');

    return $html;
};

🎯 Smart Routing with Nested Controllers

URL Pattern                →  Controller Location
/                         →  Controllers/IndexController::index()
/users                    →  Controllers/UsersController::index()
/admin/users              →  Controllers/Admin/UsersController::index()
/admin/users/edit         →  Controllers/Admin/UsersController::edit()
/api/v1/users             →  Controllers/Api/V1Controller::users()
/dashboard/analytics      →  Controllers/Dashboard/AnalyticsController::index()

🗂️ Flexible Database System

🗃️ FileDatabase (Zero Setup)

Perfect for development and rapid prototyping:

// Automatic JSON storage
$users = $this->instance->models->user->all();
$user = $this->instance->models->user->create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'created_at' => date('Y-m-d H:i:s')
]);

🐬 MySQL (Production Ready)

Seamless upgrade path for complex applications:

// Automatic detection and fallback
class UserModel extends Model {
    public function getAll() {
        if ($this->instance->database->hasMySQL()) {
            return $this->instance->database->client->select('users', '*');
        }
        return $this->fileDatabase->all('users');
    }
}

🛡️ Security First

🔒 Input Validation & Sanitization

// Built-in validation with 30+ rules
$validated = $this->instance->request->validate([
    'email' => 'required|email|unique:users',
    'password' => 'required|min:8|strong',
    'age' => 'required|integer|min:18|max:120'
]);

// Automatic XSS protection
$safeContent = $this->instance->cleaner->clean($userInput);

🔐 Authentication & Authorization

// Role-based access control
$this->instance->auth->requireGroup('admin');

// Session management
if ($this->instance->auth->login($email, $password)) {
    $user = $this->instance->auth->user();
}

📊 Production Features

High-Performance Caching

// Multi-tier caching with automatic fallback
$data = $this->instance->cache->remember('expensive.query', 3600, function() {
    return $this->instance->models->analytics->getComplexData();
});

// Tagged cache for group operations
$this->instance->cache->tags(['users'])->flush();

🔄 RESTful API Support

// Automatic content negotiation
public function api() {
    $data = $this->instance->models->user->all();

    if ($this->instance->request->wantsJson()) {
        return $this->instance->response->json($data);
    }

    $this->instance->view->render('users/index', ['users' => $data]);
}

📈 Built-in Admin Panel

Complete administrative interface with:

  • ✅ User management with modals and confirmations
  • ✅ Real-time statistics and activity monitoring
  • ✅ Role-based access control
  • ✅ Interactive data tables with action buttons
  • ✅ Responsive design for mobile administration

🚀 Deployment Options

🐳 Docker (Recommended)

# Development
docker-compose up -d

# Production
docker build -t my-app .
docker run -d -p 80:80 my-app

🌐 Traditional Hosting

# Upload files and set document root to source/public/
chmod -R 755 Application/Database/

📚 Complete API Documentation

Hoist includes comprehensive API documentation for all framework components:

Primary Storage System

  • FileDatabase API - Zero-configuration JSON database with SQL-like queries (default storage)

�🔗 Core Framework APIs

  • Authentication API - User authentication, sessions, and role-based access
  • Database API - MySQL and FileDatabase operations with query building
  • Model API - Active Record pattern with security features and validation
  • Request API - HTTP request handling, data validation, and file uploads
  • Response API - JSON responses, redirects, and content delivery
  • Router API - URL routing, parameter extraction, and nested controllers

🎨 UI and Presentation

  • View API - Template rendering, component integration, and data passing
  • Controller API - Base controller functionality and MVC patterns

🛡️ Security and Validation

  • Security API - CSRF protection, form security, and request validation
  • Validation API - Input validation with 50+ rules and custom messages
  • Session API - Session management, flash data, and state persistence

Performance and Utilities

  • Cache API - Multi-driver caching with Redis, Memcached, and file support
  • Utilities API - Helper functions for UUIDs, HTTP requests, and data processing

📖 Documentation Features

  • Complete method documentation with parameters and return types
  • Real-world examples for every API method and CLI command
  • Security best practices and implementation guidelines
  • Framework integration patterns and advanced usage
  • Enterprise-grade standards with comprehensive coverage
  • Revolutionary CLI tool with migration and code generation guides

📚 Browse All API Documentation →
🎯 View CLI Tool Documentation →


🤝 Contributing

We welcome contributions! Hoist is built by developers, for developers.

# Development setup
git clone https://github.com/RobertGrubb/hoist-php.git
cd hoist-php
docker-compose up -d

# Make your changes
git checkout -b feature/amazing-feature
# ... your improvements ...
git commit -m "Add amazing feature"
git push origin feature/amazing-feature

Contribution Areas:

  • 🎨 New UI components
  • 🔧 Framework enhancements
  • 📚 Documentation improvements
  • 🧪 Test coverage expansion
  • 🌟 Example applications

📝 License

MIT License - build amazing things with Hoist!


🚀 Get Started Today

git clone https://github.com/RobertGrubb/hoist-php.git
cd hoist-php
docker-compose up -d

Open http://localhost and start building the future! 🌟


Built with ❤️ by developers who believe great software should be simple, secure, and beautiful.

About

A PHP framework to get your site up and running fast.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages