joao-prrvz/php-utils 问题修复 & 功能扩展

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

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

joao-prrvz/php-utils

最新稳定版本:0.0.7

Composer 安装命令:

composer require joao-prrvz/php-utils

包简介

A small library made for a active record and schemas validation based workflow

README 文档

README

A small library made for a active record and schemas validation based workflow

Examples

Model exmaples

use PHPUtils\BaseModel;
use PHPUtils\Attributes\DB as DB;

class User extends BaseModel {
	// Block makes it so when generating the insert and update query it will not add the column "id" to the sql query
	#[DB\Column, DB\Block(DB\Block::INSERT, DB\Block::UPDATE)]
	public int $id;
    #[DB\Column]
	public string $username;
    #[DB\Column]
	public string $email;
	// Hidden makes it so when we do json_encode on this model it will not return the password
    #[DB\Column, DB\Hidden]
	public string $password;

	public static function selectById(int $id): User {
		return static::selectBy("id", $id);
	}

	public function insert(): int {
		$sql = static::getInsertQuery();
		$params = [
			$this->username,
			$this->email,
			$this->password,
		];
		static::run($sql, $params);
		return static::getDB()->lastInsertId();
	}

	public function update(): void {
		$params = [
			$this->username,
			$this->email,
			$this->password,
		];
		parent::updateBy("id", $this->id, $params);
	}

	public function delete(): void {
		parent::deleteBy("id", $this->id);
	}
}

// Select all is already created on BaseModel
User::selectAll();

Schema examples

use PHPUtils\BaseSchema;
use PHPUtils\Attributes\Property;
use PHPUtils\Attributes\Validators as VA;

class User extends BaseSchema {
    #[Property, VA\Min(3), VA\Max(10), VA\Filter(FILTER_SANITIZE_FULL_SPECIAL_CHARS)]
    public string $username;
    #[Property, VA\Filter(FILTER_VALIDATE_EMAIL)]
    public string $email;
    #[Property, VA\Min(8), VA\Max(20)]
    public string $password;
}
$data = [
    "username" => "My username", 
    "email" => "wrongemail",
    "password" => "password",
];

$schema = new User($data);

$result = $schema->validate();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: CC-BY-NC-4.0
  • 更新时间: 2026-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固