holkerveen/hi-framework 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

holkerveen/hi-framework

最新稳定版本:v0.3.0

Composer 安装命令:

composer require holkerveen/hi-framework

包简介

A lightweight PHP framework with routing, dependency injection, Doctrine ORM, Twig templating, and PSR-7 HTTP support

README 文档

README

This is an education yet completely useful PHP web application framework

Features

  • Attribute-Based Routing - Clean, declarative routing using PHP 8 attributes
  • Dependency Injection - Automatic constructor injection with PSR-11 container
  • Access Control - Secure by default with role-based access control
  • Doctrine ORM - Full ORM support with entity management
  • Twig Templates - Powerful templating with custom extensions
  • PSR Standards - PSR-7 (HTTP), PSR-3 (Logging), PSR-11 (Container)
  • Authentication - Built-in user authentication with session management

Requirements

  • PHP 8.4 or higher
    • with php8.4-intl extension
    • with php8.4-sqlite3 extension (should you choose to use the default db setup)
  • Composer
  • SQLite, MySQL, or PostgreSQL (for Doctrine ORM)

Getting started

composer create-project holkerveen/hi-framework-skeleton my-new-website
cd my-new-website
composer hi orm:schema-tool:create
composer hi user:create
composer serve

This creates a new project, sets up the database, creates your first user, and starts the development server.

You'll be prompted to enter an email and password for the first user.

Visit http://localhost:8000 to access your new application

Database

HiFramework uses Doctrine ORM for database management. By default, it uses SQLite for easy setup, but you can configure it to use MySQL or PostgreSQL.

Creating the Database Schema

composer run doctrine orm:schema-tool:create

Adding Your First User

Since user management requires authentication, you'll need to create your first user via the command line:

composer run hi:user:create

You'll be prompted to enter an email and password for the new user.

Other Useful Database Commands

# Update schema after entity changes
composer run doctrine orm:schema-tool:update --force

# Drop the schema
composer run doctrine orm:schema-tool:drop --force

# Validate schema
composer run doctrine orm:validate-schema

Quick Example

Once installation is finished you can start creating your application. Here are some basic examples to help you get started.

Controller

<?php
namespace App\Controllers;

use Hi\Attributes\Route;
use Hi\Attributes\AllowAccess;
use Hi\Enums\Role;
use Twig\Environment;

class HomeController
{
    #[Route('/')]
    #[AllowAccess(Role::Unauthenticated)]
    public function index(Environment $twig): string
    {
        return $twig->render('home.html.twig');
    }

    #[Route('/admin')]
    #[AllowAccess(Role::Authenticated)]
    public function admin(Environment $twig): string
    {
        return $twig->render('admin.html.twig');
    }
}

Template

<!DOCTYPE html>
<html>
<head>
    <title>My Website</title>
</head>
<body>
    <h1>Welcome</h1>

    {% if allowed('/admin') %}
        <a href="/admin">Admin Panel</a>
    {% endif %}
</body>
</html>

Credits

Built with:

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-12-25