traineratwot/web-tool-template

安装: 31

依赖: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 0

开放问题: 0

类型:项目

5.2.3 2022-12-02 07:21 UTC

This package is auto-updated.

Last update: 2024-09-05 18:38:52 UTC


README

简单的用于小型网络应用的框架

包含

  • Bootstrap - 样式
  • Jquery - JavaScript
  • Smarty - PHP 模板
  • gettext - 地区
  • LiteSql,mysql,... - 数据库

安装

  1. 将此解压到目录
  2. 运行 composer create-project traineratwot/web-tool-template {项目名称}
  3. cd {项目名称}
  4. !必填! composer update
  5. core/config.php 中配置数据库连接
  6. composer wt:Install
  7. 可选 composer wt:composer-config-update - 帮助您的 IDE 确定常数
  8. 可选 wt DevServer - 启动一个观察器,当文件更改时在浏览器中更新页面

说明

  • 文件结构
    • locale => gettext 翻译
    • core => 封闭的外部访问目录,包含系统内核
    • core/model => 包含主要脚本的目录。不要更改那里的任何内容
    • core/pages => 包含网站页面的目录。文件名应与 URL 匹配,或使用 core/router.php
    • core/view => 执行在渲染相应页面之前运行的 PHP 代码的目录。文件名应与 URL 匹配,或使用 core/router.php
    • core/templates => 包含 Smarty 模板的目录
    • core/database => 包含 SQLite 数据库的目录,您可以使用任何数据库
    • core/ajax => 包含用户可访问的 PHP 文件的目录。文件名应与表单中操作字段的名称匹配。调用 index.php?a=[无扩展名文件名]
    • core/cron/controllers=> 包含 cron 任务的目录。查看 wt cron
    • core/config.php => 主要配置文件
    • core/classes => 包含您的类和脚本的目录
    • core/classes/smarty/plugins => 包含自定义 Smarty 插件的目录
    • core/classes/tables => 扩展 BdObject 以用于数据库表操作类的目录。查看 wt make table
    • core/classes/traits => 包含有用的 traits 的目录
    • core/components => 包含组件的目录
  • 控制台工具

    • wt error - 显示错误日志

    • wt error clear - 清除错误日志

    • wt cache - 清除错误缓存

    • wt makeAjax {name} {type? 'get'|'post'} - 创建 AJAX 类方法。例如:wt make ajax "logout"

    • wt makeTable {name} {primaryKey? 'id'} - 创建对象表类。例如:wt make table "users"

    • wt makePage {url} {template? 'base'} - 为 URL 创建页面类和模板。例如:wt make page "catalog/page1 base"

    • wt makeCron {path} - 创建 cron。例如:wt make cron "category/test"

    • wt lang {locale} - 从项目源代码创建 .po 语言文件。例如:wt lang ru_RU.utf8

    • wt lang clear - 清除语言缓存。例如:wt lang clear

    • wt lang all - 显示可用的语言。例如:wt lang all

    • wt cron {controller 路径} - 生成 crontab 启动命令。例如:wt cron "category/test.php"

    • wt cron {controller 路径} run - 尝试运行 cron 任务:wt cron "category/test.php" run

    #in develop

    • components create {name} - 创建新组件
    • components package {name} - 将组件打包到传输包
    • components install {name} - 从传输包安装组件
    • components make{Ajax|Table|Page} {name} ... - 类似于 wt make... 但用于组件
  • 用户

  • 本地化

  1. 请根据您的需求在配置中修改 WT_LOCALE_SELECT_FUNCTION 函数以确定用户的语言
  2. 从项目源代码中创建本地化文件 .po,例如: wt lang ru
  3. locale 包中编辑 .po 文件。我使用 poEdit 来进行编辑
  4. 完成
  5. 如果不起作用 - 请在配置中禁用 gettext

API

缓存

/**
 * @param $key mixed
 * @param $value mixed
 * @param $expire int
 * @param $category string
 * @return mixed
 */
Cache::setCache($key,$value,$expire=600,$category = '');

/**
 * @param $key mixed
 * @param $category string
 * @return mixed|null
 */
Cache::getCache($key,$category = '');
/**
 * @param $key mixed
 * @param $category string
 * @return bool
 */
Cache::removeCache($key,$category = '');

控制台

Console::info('text') //print cyan text;
Console::success('text') //print green text;
Console::warning('text') //print yellow text;
Console::failure('text') //print red text;
Console::prompt('Are you sure you?', ?hidden)// ask user in console
/**
 * @param $string
 * @param $foreground_color
 * @param $background_color
 * @return mixed|string
 */
Console::getColoredString('text','red','yellow') //return colored string

Console::foreground_colors //list text color
Console::background_colors //list background color

配置

Config::get('key','?namespace') //return value;
Config::set('key','value','?namespace') //set value;
// тоже самое но с возможностью перезаписывать в процессе выполнения
ConfigOverridable::set('OverridableKey','value','?namespace')
ConfigOverridable::get('OverridableKey','?namespace')
Config::get('OverridableKey','?namespace') //return value;

常见问题解答

  • 作曲器出现致命错误吗?
    • 这意味着您使用的 composer 版本过旧,请更新它或使用 php composer.phar ...