├── .env ├── .gitignore ├── README.md ├── application ├── build │ ├── builder │ │ └── tinyphp.php │ ├── config │ │ └── status.php │ └── profile │ │ └── status.php ├── config │ ├── default.php │ └── ui.php ├── containers │ └── provider.php ├── controllers │ ├── console │ │ └── Main.php │ └── web │ │ └── Main.php ├── events │ └── Bootstrap.php ├── lang │ └── zh_cn │ │ └── status.php ├── profile │ ├── dev.php │ ├── prod.php │ └── test.php └── views │ ├── cache │ └── .keepgit │ ├── compile │ └── .keepgit │ ├── config │ └── .keepgit │ └── templates │ └── default │ └── main │ └── index.htm ├── composer.json ├── public └── index.php ├── resources ├── nginx │ └── tinyphp.conf ├── sql │ └── tinyphp-boostrap.sql └── tools │ └── tinyphp-daemon.sh └── var ├── cache └── .keepgit ├── log └── .keepgit └── pid └── .keepgit /.env: -------------------------------------------------------------------------------- 1 | APP_ENV=dev 2 | APP_USER=www -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .buildpath 2 | .project 3 | *.log 4 | .git 5 | *.txt 6 | .settings 7 | /vendor/ 8 | */.DS_Store 9 | */.DS_Store 10 | *.phar 11 | .env.local.php 12 | application/views/compile/* 13 | application/vieww/cache/* 14 | application/views/config/* 15 | var/cache/* 16 | var/log/* 17 | var/pid/* 18 | resource/* 19 | public/setting 20 | public/profile 21 | public/static/* 22 | composer.lock -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TinyPHP Framework for PHP 2 | ==== 3 | 4 | tinyphp v2.0.0 5 | ---- 6 | 7 | + 基于tinyphp framework v2.0.0 [https://github.com/tinyphporg/tinyphp-framework](https://github.com/tinyphporg/tinyphp-framework) 8 | 9 | > 经过日PV十亿级别生产环境检验; 10 | > 应用于高并发高性能的生产环境; 11 | > 支持分布式的RPC微服务处理; 12 | > 适用于 Web/Console/RPC等运行环境,包括单一命令行文件打包,多任务的服务端守护进等。 13 | 14 | tinyphp-framework的适用场景与理念 15 | ---- 16 | * 客户端应用(IOS/Android/H5/小程序)的API接口开发: 17 | * 高性能,大并发。 18 | * 快速开发。 19 | * 支持分布式RPC微服务架构。 20 | 21 | * Web管理后台: 22 | * 适用于PHP全栈工程师,及不具备UI设计师和前端工程师的研发团队。 23 | * 集成了tinyphp-ui前端框架,只需少量的JS前端代码。 24 | 25 | * 大规模团队协作: 26 | * 10-100+人以上的研发团队。 27 | * 创业团队,产品快速成型,可在较少的研发人力成本下进行高效的敏捷开发。 28 | * 适用于具备在大规模的高性能应用场景下,通过PHP解决大多数复杂业务的架构。 29 | * 可将大规模复杂应用的后端语言有效控制为PHP一种后端开发语言,有效降低项目维护成本和团队管理难度。 30 | 31 | 快速开始 32 | ---- 33 | ```shell 34 | composer create-project tinyphporg/tinyphp 35 | 36 | #console 运行 37 | php public/index.php 38 | 39 | #编译单文件 40 | php public/index.php --build 41 | 42 | #服务端守护进程 43 | php public/index.php -d //开启 44 | php public/index.php --daemon=stop //关闭 45 | 46 | #配置文件 47 | application/config/profile.php 48 | ``` 49 | 核心组件 50 | ==== 51 | 52 | ### tinyphp-framework v2.0 53 | + 框架地址: [https://github.com/tinyphporg/tinyphp-framework](https://github.com/tinyphporg/tinyphp-framework) 54 | 55 | ### tinyphp-docs 56 | + 中文文档: 使用手册、标准库。 57 | + 项目地址: [https://github.com//tinyphp-docs](https://github.com/tinyphporg/tinyphp-docs) 58 | 59 | ### tinyphp-ui 60 | + 前端UI组件库: webpack5+bootstrap5+jquery... 61 | + 项目地址: : [https://github.com/tinyphporg/tinyphp-ui](https://github.com/tinyphporg/tinyphp-ui) 62 | 63 | ### lnmp-utils 64 | + Linux(CentOS7X_64) +openresty(nginx)+Mysql+PHP+Redis一键安装包。 65 | + 项目地址: https://github.com/tinyphporg/lnmp-utils 66 | 67 | 快速构建运行环境 68 | ---- 69 | 70 | ### CentOS X64 7.4+ 71 | > 适应于生产环境,依赖于lnmp-utils。 72 | > lnmp-utils: Linux(CentOS7X_64) +openresty(nginx)+Mysql+PHP+Redis一键安装包。 73 | > 项目地址: https://github.com/tinyphporg/lnmp-utils 74 | 75 | ```shell 76 | git clone https://github.com/tinyphporg/lnmp-utils.git 77 | cd ./lnmp-utils 78 | ./install.sh -m tinyphp 79 | ``` 80 | 81 | ### docker 82 | > 适应于开发环境 83 | 84 | ```shell 85 | #可更改/data/workspace/tinyphp为自定义IDE工作目录 86 | workspace=/data/workspace/ 87 | 88 | docker pull centos:7 89 | docker run -d -p 80:80 -p 3306:3306 -p 8080:8080 -p 8989:8989 -p 10022:22 -v $workspace:/data/web --name="tinyphp" --hostname="tinyphp" --restart=always -w /data/worksapce/ centos:7 /sbin/init 90 | 91 | #port 8080 92 | # 用于tinyphporg/tinyphp-ui调试 93 | # npm run dev 94 | 95 | #port 8989 96 | # 用于tinyphporg/tinyphp-ui打包详情查看 97 | # npm run build 98 | 99 | docker exec -it tinyphp /bin/bash 100 | 101 | git clone https://github.com/tinyphporg/lnmp-utils.git 102 | cd ./lnmp-utils 103 | ./install.sh 104 | 105 | cd /data/web/tinyphporg/tinyphp 106 | php public/index.php 107 | 108 | ``` 109 | 110 | 中文手册 111 | ---- 112 | > 本框架的编码规范基本遵守PSR规范标准,仅少数细节做灵活调整。 113 | * [环境搭建/lnmp-utils: http://github.com/tinyphporg/lnmp-utils.git](http://github.com/tinyphporg/lnmp-utils.git) 114 | * [Demo/tinyphp: http://github.com/tinyphporg/tinyphp.git](http://github.com/tinyphporg/tinyphp.git) 115 | * [编码规范](https://github.com/tinyphporg/tinyphp-docs/tree/master/docs/coding) 116 | + [文件结构](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/file_001.md) 117 | + [程序的排版](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/program_typesetting_002.md) 118 | + [命名规则](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/rules_003.md) 119 | + [表达式和基本语句](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/expression_004.md) 120 | + [常量](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/constant_005.md) 121 | + [函数设计](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/function_006.md) 122 | + [IDE的选择](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/ide_007.md) 123 | + [编码规范的一些示例](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/coding/example_008.md) 124 | * [数据库查询/设计/操作规范](https://github.com/tinyphporg/tinyphp-docs/tree/master/docs/sql) 125 | + [查询规范](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/sql/select_001.md) 126 | + [库和表的规范](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/sql/dbtable_002.md) 127 | + [数据库设计原则](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/sql/design_003.md) 128 | + [数据库的配置优化](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/sql/optimization_004.md) 129 | * [团队协作规范](https://github.com/tinyphporg/tinyphp-docs/tree/master/docs/team) 130 | + [核心点](https://github.com/tinyphporg/tinyphp-docs/edit/master/docs/team/README.md#%E6%A0%B8%E5%BF%83%E7%82%B9) 131 | + [对于tinyphp的几个清醒认识](https://github.com/tinyphporg/tinyphp-docs/edit/master/docs/team/README.md#%E5%AF%B9%E4%BA%8E%E6%A1%86%E6%9E%B6%E7%9A%84%E5%87%A0%E4%B8%AA%E6%B8%85%E9%86%92%E8%AE%A4%E8%AF%86) 132 | + [tinyphp的适用场景与理念](https://github.com/tinyphporg/tinyphp-docs/edit/master/docs/team/README.md#tinyphp%E7%9A%84%E9%80%82%E7%94%A8%E5%9C%BA%E6%99%AF%E4%B8%8E%E7%90%86%E5%BF%B5) 133 | + [MVC的协作规范](https://github.com/tinyphporg/tinyphp-docs/edit/master/docs/team/README.md#mvc%E7%9A%84%E5%8D%8F%E4%BD%9C%E8%A7%84%E8%8C%83) 134 | + [tinyphp的系统设计原则](https://github.com/tinyphporg/tinyphp-docs/edit/master/docs/team/README.md#tinyphp%E7%9A%84%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%E5%8E%9F%E5%88%99) 135 | * [框架使用手册](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/) 136 | + [Index/入口文件: public/index.php](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/index.md) 137 | + [Runtime/运行时环境: runtime/](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime.md) 138 | - [Environment/运行时环境参数](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime_env.md) 139 | - [ExceptionHandler/异常处理](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime_exception.md) 140 | - [Autoloader/自动加载](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime_autoloader.md) 141 | - [Container/容器](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime_container.md) 142 | - [EventManager/事件管理](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/runtime_event.md) 143 | + [Application/应用程序: application/](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/application.md) 144 | - [Proptrites/Application配置文件:application/config/profile.php](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/profile.md) 145 | - [Debug/调试模式配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/debug.md) 146 | - [Bootstrap/引导程序配置:application/events/Bootstrap.php](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/bootstrap.md) 147 | - [Lang/语言包配置:application/lang](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/lang.md) 148 | - [Data/数据源配置:/application/data](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/data.md) 149 | - [Cache/缓存配置:runtime/cache](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/cache.md) 150 | - [Logger/日志收集配置:runtime/log](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/logger.md) 151 | - [Configuration/配置类配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/configuration.md) 152 | - [Builder/打包单文件的配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/builder.md) 153 | - [Daemon/守护进程配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/daemon.md) 154 | - [Filter/过滤器配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/filter.md) 155 | - [MVC/Event/事件配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_event.md) 156 | - [MVC/Controller/控制器配置:application/controllers/](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_controller.md) 157 | - [MVC/Model/模型配置:application/models/](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_model.md) 158 | - [MVC/Viewer/视图配置:application/views/](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_viewer.md) 159 | - [MVC/Router/路由器配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_router.md) 160 | - [MVC/Controller/Dispatcher/派发器配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_dispatcher.md) 161 | - [MVC/Request/请求](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_request.md) 162 | - [MVC/Response/响应](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_response.md) 163 | - [MVC/Web/HttpCookie](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_cookie.md) 164 | - [Mvc/Web/HttpSession](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/manual/mvc_session.md) 165 | 166 | * [框架标准库参考](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/) 167 | * [Tiny:工具包](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/tiny.md) 168 | * [Tiny\Runtime:运行时](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/runtime.md) 169 | * [Tiny\Build:打包](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/build.md) 170 | * [Tiny\Cache:缓存](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/cache.md) 171 | * [Tiny\Config:配置](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/config.md) 172 | * [Tiny\Console:命令行](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/console.md) 173 | * [Tiny\Data:数据层](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/data.md) 174 | * [Tiny\DI:依赖注入](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/di.md) 175 | * [Tiny\Event:事件](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/event.md) 176 | * [Tiny\Filter:过滤器](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/filter.md) 177 | * [Tiny\Image:图片处理](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/image.md) 178 | * [Tiny\Lang:语言包](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/lang.md) 179 | * [Tiny\Log:日志处理](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/log.md) 180 | * [Tiny\MVC:MVC](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/mvc.md) 181 | * [Tiny\Net:网络](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/net.md) 182 | * [Tiny\String:字符处理](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/lib/string.md) 183 | 184 | * [UI库参考](https://github.com/tinyphporg/tinyphp-docs/blob/master/docs/ui/) 185 | -------------------------------------------------------------------------------- /application/build/builder/tinyphp.php: -------------------------------------------------------------------------------- 1 | tinyphp-demo.phar 21 | * 22 | * header_php_env 是否在打包文件首行添加PHP运行环境 23 | * example: #!/usr/bin/php 24 | * 运行单文件的方式可由php tinyphp-demo.phar 变为 ./tinyphp-demo 25 | * 26 | * namespaces [namespace => dirname] 27 | * 加载命名空间对应的加载目录和路径 28 | * 29 | * controller 运行单文件时的默认控制器 30 | * 31 | * action 运行单文件时的默认动作 32 | * 33 | * framework_path 框架源代码目录 34 | * 35 | * vendor_path composer库引入的目录路径 36 | * 37 | * exclude 打包时忽略的文件正则 38 | * 39 | * attachments => [dirname...] 40 | * 运行单文件时解压在单文件所在目录的文件和文件夹 41 | * example: ['config/app', APPLICATION_PATH . 'config/'], 42 | * 43 | * home_attachments => [dirname...] 44 | * 运行单文件时解压在单文件用户所在目录的文件和文件夹 45 | * example : 用户为wwww,解压目录则为 /home/www/.tinyphp-demo 46 | * ] 47 | */ 48 | return [ 49 | 'name' => 'tinyphp', 50 | 'header_php_env' => true, 51 | 'extname' => '', 52 | 'dist' => 'bin', 53 | 'namespaces' => [], 54 | 'controller' => 'main', 55 | 'help' => ['/main/build' => 'builder 测试'], 56 | 'action' => 'build', 57 | 'exclude' => ["/\.(git|buildpath|project|dat|log|settings|md|svn)$/","/vendor\/smarty\/smarty/", "/tinyphp-ui\/(node_modules|src\/js|conf|dist|build|templates\/pages\/)/"], 58 | 'attachments' => [], 59 | 'home_attachments' => [], 60 | ]; 61 | ?> -------------------------------------------------------------------------------- /application/build/config/status.php: -------------------------------------------------------------------------------- 1 | "config.index" . __FILE__ 4 | ]; 5 | ?> -------------------------------------------------------------------------------- /application/build/profile/status.php: -------------------------------------------------------------------------------- 1 | "profile.index" . __FILE__ 4 | ]; 5 | ?> -------------------------------------------------------------------------------- /application/config/default.php: -------------------------------------------------------------------------------- 1 | 'TinyPHP Framework', 4 | 'version' => '2.0.0', 5 | 'example' => 'tinyphp config example' 6 | ]; 7 | ?> -------------------------------------------------------------------------------- /application/config/ui.php: -------------------------------------------------------------------------------- 1 | 'tinyphp' 5 | ]; 6 | ?> -------------------------------------------------------------------------------- /application/containers/provider.php: -------------------------------------------------------------------------------- 1 | [别名 => class name], 19 | * 20 | * 可在class文件的注释里@autowired自动注解,可自动加载,无需在容器配置文件内配置 21 | * 22 | * 通过类名自动加载 23 | * class name => class name 24 | * 25 | * 通过匿名函数加载实例 26 | * class => function(){ 27 | * return new ClassName(); 28 | * } 29 | */ 30 | return [ 31 | 'alias' => [ 32 | 'bootstrap' => Bootstrap::class 33 | ], 34 | 35 | ]; 36 | ?> -------------------------------------------------------------------------------- /application/controllers/console/Main.php: -------------------------------------------------------------------------------- 1 | app = $app; 44 | } 45 | 46 | /** 47 | * 测试 48 | */ 49 | public function testAction() 50 | { 51 | echo "console test"; 52 | sleep(2); 53 | } 54 | 55 | /** 56 | * 测试单文件打包后的本地配置项 57 | * 58 | * @param ApplicationBase $app 59 | */ 60 | public function buildAction(Properties $properties, Configuration $config) 61 | { 62 | echo sprintf("config.status.index: %s \n", $config['status.index']); 63 | echo sprintf("properties.status.index: %s \n", $properties['status.index']); 64 | } 65 | 66 | /** 67 | * 测试首页 68 | * 69 | * @param Lang $lang 70 | * @param Configuration $config 71 | */ 72 | public function indexAction(Lang $lang, Configuration $config) 73 | { 74 | $actionName = $this->request->getActionName(); 75 | $controllerName = $this->request->getControllerName(); 76 | $isName = $this->request->param->isRequired('name') ? 'true' : 'false'; 77 | $name = $this->request->param['name']; 78 | $output = [ 79 | 'actionName' => $actionName, 80 | 'controllerName' => $controllerName, 81 | 'name' => $name, 82 | 'defName' => 'tinyphp', 83 | 'isName' => $isName, 84 | ]; 85 | $this->response->outFormatJSON(0, $config['example.default.b'], $output); 86 | } 87 | } 88 | ?> -------------------------------------------------------------------------------- /application/controllers/web/Main.php: -------------------------------------------------------------------------------- 1 | has(ModuleManager::class)) { 44 | $moduleManager = $container->get(ModuleManager::class); 45 | if ($moduleManager->has('tinyphp-ui')) { 46 | $this->response->redirect('/uidemo/docs/readme.html'); 47 | } 48 | } 49 | $this->display('main/index.htm'); 50 | } 51 | 52 | public function testAction(View $view, Cache $cache) 53 | { 54 | $cache->set('a', 'sdfdsfgsdfsdfsd'); 55 | echo $cache->get('a'); 56 | echo 'vbvv'; 57 | //$view->messagebox->show(['content' => 'aaa']); 58 | } 59 | } 60 | ?> -------------------------------------------------------------------------------- /application/events/Bootstrap.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /application/lang/zh_cn/status.php: -------------------------------------------------------------------------------- 1 | "success %s", 4 | 10001 => "faild %s" 5 | ]; 6 | ?> -------------------------------------------------------------------------------- /application/profile/dev.php: -------------------------------------------------------------------------------- 1 | 调用时使用的ID字段 53 | * host 通用的远程资源 54 | * prot 通用的远程端口 55 | * charset utf8mb4 兼容表情包 56 | * password 通用密码 57 | * dbname 数据库名称 58 | * ] 59 | * 60 | * redis驱动 61 | * driver = redis [ 62 | * id => 调用时使用的ID字段 63 | * host => 远程host 单独设置的host & prot 会合并到servers内 64 | * port => 远程端口 65 | * db => 选择的DB Index 66 | * servers => [[host => 服务, port => 端口]] 67 | * ] 68 | * 69 | * memcache驱动 70 | * driver = memcached [ 71 | * servers => [[host=> 服务地址, port=> 端口]] 72 | * persistent_id => 共享实例的ID 73 | * options => [选项] 74 | * ] 75 | */ 76 | $profile['data']['sources'] = [ 77 | ['id' => 'default', 'driver' => 'db.mysqli', 'host' => '127.0.0.1', 'port' => '3306', 'user' => 'root', 'password' => '123456', 'dbname' => 'mysql'], 78 | ['id' => 'redis', 'driver' => 'redis', 'host' => '127.0.0.1', 'port' => '6379', 'db' => 0], 79 | ['id' => 'redis_cache', 'driver' => 'redis', 'db' => 1, 'servers' => [['host' => '127.0.0.1', 'port' => '6379']]], 80 | ['id' => 'redis_session', 'driver' => 'redis', 'db' => 2, 'host' => '127.0.0.1', 'port' => '6379'], 81 | ['id' => 'redis_queue', 'driver' => 'redis', 'db' => 3, 'host' => '127.0.0.1', 'port' => '6379'], 82 | ['id' => 'memcached', 'driver' => 'memcached', 'servers' => [['host' => '127.0.0.1', 'port' => '11211']], 'persistent_id' => null, 'options' => []] 83 | ]; 84 | 85 | 86 | /** 87 | * 服务端守护进程的基本设置 88 | * 89 | * 仅在命令行环境的ConsoleApplication实例生效 90 | * 91 | * daemon.enabled 92 | * 是否开启自动监听Daemon的命令行参数监听 93 | * 94 | * daemon.id 默认启动的服务ID 95 | * id 即 daemon.policys数组里的key 96 | * 97 | * daemon.event_listener Daemon事件监听器 98 | * 监听D命令行的-d --daemon参数 并实例化Daemon 99 | * 100 | * daemon.piddir 101 | * 守护进程的PID保存目录 102 | * 103 | * daemon.tick 104 | * 默认子进程退出后重建的间隔 105 | * 106 | * daemon.daemons 配置服务数组 107 | * daemonid => [ 108 | * workers,子进程配置 109 | * options => 附加给当前服务实例的选项 110 | * ] 111 | * workers的配置: 【 112 | * id => worker的身份标识 113 | * type => worker worker类型,默认为限定循环执行的子进程模式 114 | * dispatcher => [controller,action,module]代理执行worker进程的控制器,动作参数, 模块 115 | * num => 子进程的数量 116 | * options => [] 附加给worker实例的参数 117 | * type = worker: 118 | * options => [ 119 | * runmax => 最大运行次数,避免内存占用过多系统阻塞 120 | * tick => 重建子进程的间隔 121 | * ] 122 | * 】 123 | */ 124 | $profile['daemon']['daemons'] = [ 125 | 'tinyphp-daemon' => [ 126 | 'workers' => [ 127 | ['id' => 'index', 'type' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'index', "module" => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '10']], 128 | ['id' => 'test', 'worker' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'test', 'module' => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '1']] 129 | ], 130 | 'options' => [], 131 | ] 132 | ]; 133 | 134 | 135 | /** 136 | * Application的缓存设置 137 | * 138 | * 支持的存储器类型 139 | * file => Tiny\Cache\Storager\File 文件存储 140 | * memcached => Tiny\Cache\Storager\Memcached memcache存储 141 | * php => Tiny\Cache\Storager\PHP PHP文件序列化存储 142 | * redis => Tiny\Cache\Storager\Redis Redis存储 143 | * SingleCache => Tiny\Cache\Storager\SingleCache 单文件存储 适合小数据快速缓存 144 | * 145 | * cache.enabled 开始缓存 146 | * true 开启 | false 关闭 147 | * 148 | * cache.ttl 默认的缓存过期时间 149 | * ttl 可单独设置 150 | * 151 | * cache.dir 默认的本地文件缓存路径 152 | * string dir 只可设置为文件夹 153 | * 154 | * cache.application_storager 155 | * string 当前应用实例的缓存存储器 156 | * 157 | * cache.default_id 默认的缓存资源ID 158 | * $cache 将缓存实例当缓存调用时所调用的cacheID 159 | * 160 | * cache.application 161 | * 是否对application的lang container config等数据进行缓存 162 | * 163 | * cache.storagers 缓存存储器的注册列表 164 | * [ 165 | * key => value 166 | * 存储器ID => 存储器类全程 167 | * 'file' => \Tiny\Cache\File::class 168 | * ] 169 | * 添加后,即可在cache.sources节点的storager引用 170 | * 171 | * cache.sources 缓存源 172 | * 本框架的远程缓存源通过datasource统一调度管理 173 | * id => 调用缓存资源的ID 174 | * storager = redis [ 175 | * options => [ 176 | * ttl => 默认过期时间 177 | * dataid => 调用的data sources ID 178 | * ] 179 | * ] 180 | * 181 | * storager => memcached [ 182 | * options => [ 183 | * ttl => 默认的过期时间 184 | * dataid => 调用的data source id 185 | * ] 186 | * 187 | * ] 188 | * 189 | * storager => file [ 190 | * options => 191 | * ] 192 | */ 193 | $profile['cache']['sources'] = [ 194 | ['id' => 'default', 'storager' => 'redis', 'options' => ['ttl' => 3600, 'dataid' => 'redis_cache']], 195 | ['id' => 'memcached', 'storager' => 'memcached', 'options' => ['ttl' => 3600, 'dataid' => 'memcached']], 196 | ]; 197 | 198 | 199 | /** 200 | * HTTP SESSION设置 201 | * 202 | * 仅在WEB环境下有效 203 | * 204 | * session.enabled 205 | * 开启框架自动代理SESSION处理 206 | * 207 | * session.domain 208 | * session cookie生效的域名设置 209 | * 210 | * session.path 211 | * session cookie生效的路径设置 212 | * 213 | * session.expires 214 | * SESSION过期时间 215 | * 216 | * session.adapters 添加自定义的SESSION适配器 217 | * adapterid 适配器ID 218 | * adapterClass 实现了session适配器接口的自定义session adapter class 219 | * 220 | * session.adapter SESSION适配器 221 | * redis 以datasource的redis实例作为session适配器 222 | * memcache 以datasource的rmemcached实例作为session适配器 223 | * 224 | * session.dataid 225 | * 根据session.adapter选择对应的data资源实例 226 | * */ 227 | $profile['session']['enabled'] = true; 228 | $profile['session']['adapter'] = 'redis'; 229 | $profile['session']['dataid'] = 'redis_session'; 230 | 231 | 232 | /** 233 | * 模块的静态公共资源配置 234 | * 235 | * module.static.enabled 是否开启静态资源的自动复制 236 | * true 开启 237 | * 238 | * module.static.web WEB环境下是否自动开启静态资源复制 239 | * true 开启 会影响web下的某些性能 240 | * 241 | * module.static.basedir 静态公共资源复制的目录 242 | * 243 | */ 244 | $profile['module']['static']['enabled'] = true; 245 | $profile['module']['static']['web'] = true; 246 | $profile['module']['static']['basedir'] = '{path.static}'; 247 | 248 | 249 | /** 250 | * tinyphp-ui 前端库设置 251 | * 252 | * module.tinyphp-ui.enabled 开启 253 | * true 开启前确认是否通过composer/框架加载,引入了tinyphporg/tinyphp-ui模块 254 | * 255 | * module.tinyphp-ui.public_path 在前端源码展示的公共路径、 256 | * 257 | * 根目录下的绝对路径 /tinyphp-ui 258 | * 包含域名的绝对路径 比如cdn域名, demo.xxx.com/tinyphp-ui/ 259 | * 260 | * module.tinyphp-ui.inject 261 | * 是否自动将ui库的公共路径,注入到html源码 262 | * 仅支持engine = template时 263 | * 264 | * module.tinyphp-ui.helper 265 | * ui前端库在view注册的助手类 266 | * message 提示消息体 267 | * pagination 分页 268 | * 269 | * module.tinyphp-ui.template_dirname 270 | * UI库的视图模板路径 271 | * 272 | * module.tinyphp-ui.dev_enabled 是否开启UI调试 273 | * 必须在tinyphp-ui 运行npm run dev后开启调试模式 274 | * 275 | * module.tinyphp-ui.dev_public_path 276 | * 调试库在前端展现的URL 相对于view.public_path的路径 277 | * 278 | * module.tinyphp-ui.dev_event_listener 279 | * 开启调试后的监听事件类 280 | * 281 | * module.tinyphp-ui.assigns array 282 | * 预设的配置变量注入到视图模板内 283 | * example: ui 即寻找tinyphp-ui.config内的ui节点,与application.config的ui节点合并,并以$ui注入到视图变量 284 | */ 285 | $profile['module']['tinyphp-ui']['enabled'] = true; 286 | $profile['module']['tinyphp-ui']['public_path'] = '/static/tinyphp-ui/'; 287 | $profile['module']['tinyphp-ui']['inject'] = true; 288 | 289 | // UI前端模块的开发设置 可选 290 | $profile['module']['tinyphp-ui']['dev']['enabled'] = true; 291 | $profile['module']['tinyphp-ui']['dev']['dev_public_path'] = "http://127.0.0.1:8080/"; 292 | 293 | // 将预设配置的变量注入到视图模板 294 | $profile['module']['tinyphp-ui']['assigns'] = ['ui']; 295 | 296 | return $profile; 297 | ?> -------------------------------------------------------------------------------- /application/profile/prod.php: -------------------------------------------------------------------------------- 1 | 调用时使用的ID字段 53 | * host 通用的远程资源 54 | * prot 通用的远程端口 55 | * charset utf8mb4 兼容表情包 56 | * password 通用密码 57 | * dbname 数据库名称 58 | * ] 59 | * 60 | * redis驱动 61 | * driver = redis [ 62 | * id => 调用时使用的ID字段 63 | * host => 远程host 单独设置的host & prot 会合并到servers内 64 | * port => 远程端口 65 | * db => 选择的DB Index 66 | * servers => [[host => 服务, port => 端口]] 67 | * ] 68 | * 69 | * memcache驱动 70 | * driver = memcached [ 71 | * servers => [[host=> 服务地址, port=> 端口]] 72 | * persistent_id => 共享实例的ID 73 | * options => [选项] 74 | * ] 75 | */ 76 | $profile['data']['sources'] = [ 77 | ['id' => 'default', 'driver' => 'db.mysqli', 'host' => '127.0.0.1', 'port' => '3306', 'user' => 'root', 'password' => '123456', 'dbname' => 'mysql'], 78 | ['id' => 'redis', 'driver' => 'redis', 'host' => '127.0.0.1', 'port' => '6379', 'db' => 0], 79 | ['id' => 'redis_cache', 'driver' => 'redis', 'db' => 1, 'servers' => [['host' => '127.0.0.1', 'port' => '6379']]], 80 | ['id' => 'redis_session', 'driver' => 'redis', 'db' => 2, 'host' => '127.0.0.1', 'port' => '6379'], 81 | ['id' => 'redis_queue', 'driver' => 'redis', 'db' => 3, 'host' => '127.0.0.1', 'port' => '6379'], 82 | ['id' => 'memcached', 'driver' => 'memcached', 'servers' => [['host' => '127.0.0.1', 'port' => '11211']], 'persistent_id' => null, 'options' => []] 83 | ]; 84 | 85 | 86 | /** 87 | * 服务端守护进程的基本设置 88 | * 89 | * 仅在命令行环境的ConsoleApplication实例生效 90 | * 91 | * daemon.enabled 92 | * 是否开启自动监听Daemon的命令行参数监听 93 | * 94 | * daemon.id 默认启动的服务ID 95 | * id 即 daemon.policys数组里的key 96 | * 97 | * daemon.event_listener Daemon事件监听器 98 | * 监听D命令行的-d --daemon参数 并实例化Daemon 99 | * 100 | * daemon.piddir 101 | * 守护进程的PID保存目录 102 | * 103 | * daemon.tick 104 | * 默认子进程退出后重建的间隔 105 | * 106 | * daemon.daemons 配置服务数组 107 | * daemonid => [ 108 | * workers,子进程配置 109 | * options => 附加给当前服务实例的选项 110 | * ] 111 | * workers的配置: 【 112 | * id => worker的身份标识 113 | * type => worker worker类型,默认为限定循环执行的子进程模式 114 | * dispatcher => [controller,action,module]代理执行worker进程的控制器,动作参数, 模块 115 | * num => 子进程的数量 116 | * options => [] 附加给worker实例的参数 117 | * type = worker: 118 | * options => [ 119 | * runmax => 最大运行次数,避免内存占用过多系统阻塞 120 | * tick => 重建子进程的间隔 121 | * ] 122 | * 】 123 | */ 124 | $profile['daemon']['daemons'] = [ 125 | 'tinyphp-daemon' => [ 126 | 'workers' => [ 127 | ['id' => 'index', 'type' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'index', "module" => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '10']], 128 | ['id' => 'test', 'worker' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'test', 'module' => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '1']] 129 | ], 130 | 'options' => [], 131 | ] 132 | ]; 133 | 134 | 135 | /** 136 | * Application的缓存设置 137 | * 138 | * 支持的存储器类型 139 | * file => Tiny\Cache\Storager\File 文件存储 140 | * memcached => Tiny\Cache\Storager\Memcached memcache存储 141 | * php => Tiny\Cache\Storager\PHP PHP文件序列化存储 142 | * redis => Tiny\Cache\Storager\Redis Redis存储 143 | * SingleCache => Tiny\Cache\Storager\SingleCache 单文件存储 适合小数据快速缓存 144 | * 145 | * cache.enabled 开始缓存 146 | * true 开启 | false 关闭 147 | * 148 | * cache.ttl 默认的缓存过期时间 149 | * ttl 可单独设置 150 | * 151 | * cache.dir 默认的本地文件缓存路径 152 | * string dir 只可设置为文件夹 153 | * 154 | * cache.application_storager 155 | * string 当前应用实例的缓存存储器 156 | * 157 | * cache.default_id 默认的缓存资源ID 158 | * $cache 将缓存实例当缓存调用时所调用的cacheID 159 | * 160 | * cache.application 161 | * 是否对application的lang container config等数据进行缓存 162 | * 163 | * cache.storagers 缓存存储器的注册列表 164 | * [ 165 | * key => value 166 | * 存储器ID => 存储器类全程 167 | * 'file' => \Tiny\Cache\File::class 168 | * ] 169 | * 添加后,即可在cache.sources节点的storager引用 170 | * 171 | * cache.sources 缓存源 172 | * 本框架的远程缓存源通过datasource统一调度管理 173 | * id => 调用缓存资源的ID 174 | * storager = redis [ 175 | * options => [ 176 | * ttl => 默认过期时间 177 | * dataid => 调用的data sources ID 178 | * ] 179 | * ] 180 | * 181 | * storager => memcached [ 182 | * options => [ 183 | * ttl => 默认的过期时间 184 | * dataid => 调用的data source id 185 | * ] 186 | * 187 | * ] 188 | * 189 | * storager => file [ 190 | * options => 191 | * ] 192 | */ 193 | $profile['cache']['sources'] = [ 194 | ['id' => 'default', 'storager' => 'redis', 'options' => ['ttl' => 3600, 'dataid' => 'redis_cache']], 195 | ['id' => 'memcached', 'storager' => 'memcached', 'options' => ['ttl' => 3600, 'dataid' => 'memcached']], 196 | ]; 197 | 198 | 199 | /** 200 | * HTTP SESSION设置 201 | * 202 | * 仅在WEB环境下有效 203 | * 204 | * session.enabled 205 | * 开启框架自动代理SESSION处理 206 | * 207 | * session.domain 208 | * session cookie生效的域名设置 209 | * 210 | * session.path 211 | * session cookie生效的路径设置 212 | * 213 | * session.expires 214 | * SESSION过期时间 215 | * 216 | * session.adapters 添加自定义的SESSION适配器 217 | * adapterid 适配器ID 218 | * adapterClass 实现了session适配器接口的自定义session adapter class 219 | * 220 | * session.adapter SESSION适配器 221 | * redis 以datasource的redis实例作为session适配器 222 | * memcache 以datasource的rmemcached实例作为session适配器 223 | * 224 | * session.dataid 225 | * 根据session.adapter选择对应的data资源实例 226 | * */ 227 | $profile['session']['enabled'] = true; 228 | $profile['session']['adapter'] = 'redis'; 229 | $profile['session']['dataid'] = 'redis_session'; 230 | 231 | 232 | /** 233 | * 模块的静态公共资源配置 234 | * 235 | * module.static.enabled 是否开启静态资源的自动复制 236 | * true 开启 237 | * 238 | * module.static.web WEB环境下是否自动开启静态资源复制 239 | * true 开启 会影响web下的某些性能 240 | * 241 | * module.static.basedir 静态公共资源复制的目录 242 | * 243 | */ 244 | $profile['module']['static']['enabled'] = true; 245 | $profile['module']['static']['web'] = true; 246 | $profile['module']['static']['basedir'] = '{path.static}'; 247 | 248 | 249 | /** 250 | * tinyphp-ui 前端库设置 251 | * 252 | * module.tinyphp-ui.enabled 开启 253 | * true 开启前确认是否通过composer/框架加载,引入了tinyphporg/tinyphp-ui模块 254 | * 255 | * module.tinyphp-ui.public_path 在前端源码展示的公共路径、 256 | * 257 | * 根目录下的绝对路径 /tinyphp-ui 258 | * 包含域名的绝对路径 比如cdn域名, demo.xxx.com/tinyphp-ui/ 259 | * 260 | * module.tinyphp-ui.inject 261 | * 是否自动将ui库的公共路径,注入到html源码 262 | * 仅支持engine = template时 263 | * 264 | * module.tinyphp-ui.helper 265 | * ui前端库在view注册的助手类 266 | * message 提示消息体 267 | * pagination 分页 268 | * 269 | * module.tinyphp-ui.template_dirname 270 | * UI库的视图模板路径 271 | * 272 | * module.tinyphp-ui.dev_enabled 是否开启UI调试 273 | * 必须在tinyphp-ui 运行npm run dev后开启调试模式 274 | * 275 | * module.tinyphp-ui.dev_public_path 276 | * 调试库在前端展现的URL 相对于view.public_path的路径 277 | * 278 | * module.tinyphp-ui.dev_event_listener 279 | * 开启调试后的监听事件类 280 | * 281 | * module.tinyphp-ui.assigns array 282 | * 预设的配置变量注入到视图模板内 283 | * example: ui 即寻找tinyphp-ui.config内的ui节点,与application.config的ui节点合并,并以$ui注入到视图变量 284 | */ 285 | $profile['module']['tinyphp-ui']['enabled'] = true; 286 | $profile['module']['tinyphp-ui']['public_path'] = '/static/tinyphp-ui/'; 287 | $profile['module']['tinyphp-ui']['inject'] = true; 288 | 289 | // UI前端模块的开发设置 可选 290 | $profile['module']['tinyphp-ui']['dev']['enabled'] = false; 291 | $profile['module']['tinyphp-ui']['dev']['dev_public_path'] = "http://127.0.0.1:8080/"; 292 | 293 | // 将预设配置的变量注入到视图模板 294 | $profile['module']['tinyphp-ui']['assigns'] = ['ui']; 295 | 296 | return $profile; 297 | ?> -------------------------------------------------------------------------------- /application/profile/test.php: -------------------------------------------------------------------------------- 1 | 调用时使用的ID字段 53 | * host 通用的远程资源 54 | * prot 通用的远程端口 55 | * charset utf8mb4 兼容表情包 56 | * password 通用密码 57 | * dbname 数据库名称 58 | * ] 59 | * 60 | * redis驱动 61 | * driver = redis [ 62 | * id => 调用时使用的ID字段 63 | * host => 远程host 单独设置的host & prot 会合并到servers内 64 | * port => 远程端口 65 | * db => 选择的DB Index 66 | * servers => [[host => 服务, port => 端口]] 67 | * ] 68 | * 69 | * memcache驱动 70 | * driver = memcached [ 71 | * servers => [[host=> 服务地址, port=> 端口]] 72 | * persistent_id => 共享实例的ID 73 | * options => [选项] 74 | * ] 75 | */ 76 | $profile['data']['sources'] = [ 77 | ['id' => 'default', 'driver' => 'db.mysqli', 'host' => '127.0.0.1', 'port' => '3306', 'user' => 'root', 'password' => '123456', 'dbname' => 'mysql'], 78 | ['id' => 'redis', 'driver' => 'redis', 'host' => '127.0.0.1', 'port' => '6379', 'db' => 0], 79 | ['id' => 'redis_cache', 'driver' => 'redis', 'db' => 1, 'servers' => [['host' => '127.0.0.1', 'port' => '6379']]], 80 | ['id' => 'redis_session', 'driver' => 'redis', 'db' => 2, 'host' => '127.0.0.1', 'port' => '6379'], 81 | ['id' => 'redis_queue', 'driver' => 'redis', 'db' => 3, 'host' => '127.0.0.1', 'port' => '6379'], 82 | ['id' => 'memcached', 'driver' => 'memcached', 'servers' => [['host' => '127.0.0.1', 'port' => '11211']], 'persistent_id' => null, 'options' => []] 83 | ]; 84 | 85 | 86 | /** 87 | * 服务端守护进程的基本设置 88 | * 89 | * 仅在命令行环境的ConsoleApplication实例生效 90 | * 91 | * daemon.enabled 92 | * 是否开启自动监听Daemon的命令行参数监听 93 | * 94 | * daemon.id 默认启动的服务ID 95 | * id 即 daemon.policys数组里的key 96 | * 97 | * daemon.event_listener Daemon事件监听器 98 | * 监听D命令行的-d --daemon参数 并实例化Daemon 99 | * 100 | * daemon.piddir 101 | * 守护进程的PID保存目录 102 | * 103 | * daemon.tick 104 | * 默认子进程退出后重建的间隔 105 | * 106 | * daemon.daemons 配置服务数组 107 | * daemonid => [ 108 | * workers,子进程配置 109 | * options => 附加给当前服务实例的选项 110 | * ] 111 | * workers的配置: 【 112 | * id => worker的身份标识 113 | * type => worker worker类型,默认为限定循环执行的子进程模式 114 | * dispatcher => [controller,action,module]代理执行worker进程的控制器,动作参数, 模块 115 | * num => 子进程的数量 116 | * options => [] 附加给worker实例的参数 117 | * type = worker: 118 | * options => [ 119 | * runmax => 最大运行次数,避免内存占用过多系统阻塞 120 | * tick => 重建子进程的间隔 121 | * ] 122 | * 】 123 | */ 124 | $profile['daemon']['daemons'] = [ 125 | 'tinyphp-daemon' => [ 126 | 'workers' => [ 127 | ['id' => 'index', 'type' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'index', "module" => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '10']], 128 | ['id' => 'test', 'worker' => 'worker' , 'dispatcher' => ['controller' => 'main', 'action' => 'test', 'module' => ''], 'num' => 1, 'options' => ['runmax' => 1024, 'tick' => '1']] 129 | ], 130 | 'options' => [], 131 | ] 132 | ]; 133 | 134 | 135 | /** 136 | * Application的缓存设置 137 | * 138 | * 支持的存储器类型 139 | * file => Tiny\Cache\Storager\File 文件存储 140 | * memcached => Tiny\Cache\Storager\Memcached memcache存储 141 | * php => Tiny\Cache\Storager\PHP PHP文件序列化存储 142 | * redis => Tiny\Cache\Storager\Redis Redis存储 143 | * SingleCache => Tiny\Cache\Storager\SingleCache 单文件存储 适合小数据快速缓存 144 | * 145 | * cache.enabled 开始缓存 146 | * true 开启 | false 关闭 147 | * 148 | * cache.ttl 默认的缓存过期时间 149 | * ttl 可单独设置 150 | * 151 | * cache.dir 默认的本地文件缓存路径 152 | * string dir 只可设置为文件夹 153 | * 154 | * cache.application_storager 155 | * string 当前应用实例的缓存存储器 156 | * 157 | * cache.default_id 默认的缓存资源ID 158 | * $cache 将缓存实例当缓存调用时所调用的cacheID 159 | * 160 | * cache.application 161 | * 是否对application的lang container config等数据进行缓存 162 | * 163 | * cache.storagers 缓存存储器的注册列表 164 | * [ 165 | * key => value 166 | * 存储器ID => 存储器类全程 167 | * 'file' => \Tiny\Cache\File::class 168 | * ] 169 | * 添加后,即可在cache.sources节点的storager引用 170 | * 171 | * cache.sources 缓存源 172 | * 本框架的远程缓存源通过datasource统一调度管理 173 | * id => 调用缓存资源的ID 174 | * storager = redis [ 175 | * options => [ 176 | * ttl => 默认过期时间 177 | * dataid => 调用的data sources ID 178 | * ] 179 | * ] 180 | * 181 | * storager => memcached [ 182 | * options => [ 183 | * ttl => 默认的过期时间 184 | * dataid => 调用的data source id 185 | * ] 186 | * 187 | * ] 188 | * 189 | * storager => file [ 190 | * options => 191 | * ] 192 | */ 193 | $profile['cache']['sources'] = [ 194 | ['id' => 'default', 'storager' => 'redis', 'options' => ['ttl' => 3600, 'dataid' => 'redis_cache']], 195 | ['id' => 'memcached', 'storager' => 'memcached', 'options' => ['ttl' => 3600, 'dataid' => 'memcached']], 196 | ]; 197 | 198 | 199 | /** 200 | * HTTP SESSION设置 201 | * 202 | * 仅在WEB环境下有效 203 | * 204 | * session.enabled 205 | * 开启框架自动代理SESSION处理 206 | * 207 | * session.domain 208 | * session cookie生效的域名设置 209 | * 210 | * session.path 211 | * session cookie生效的路径设置 212 | * 213 | * session.expires 214 | * SESSION过期时间 215 | * 216 | * session.adapters 添加自定义的SESSION适配器 217 | * adapterid 适配器ID 218 | * adapterClass 实现了session适配器接口的自定义session adapter class 219 | * 220 | * session.adapter SESSION适配器 221 | * redis 以datasource的redis实例作为session适配器 222 | * memcache 以datasource的rmemcached实例作为session适配器 223 | * 224 | * session.dataid 225 | * 根据session.adapter选择对应的data资源实例 226 | * */ 227 | $profile['session']['enabled'] = true; 228 | $profile['session']['adapter'] = 'redis'; 229 | $profile['session']['dataid'] = 'redis_session'; 230 | 231 | 232 | /** 233 | * 模块的静态公共资源配置 234 | * 235 | * module.static.enabled 是否开启静态资源的自动复制 236 | * true 开启 237 | * 238 | * module.static.web WEB环境下是否自动开启静态资源复制 239 | * true 开启 会影响web下的某些性能 240 | * 241 | * module.static.basedir 静态公共资源复制的目录 242 | * 243 | */ 244 | $profile['module']['static']['enabled'] = true; 245 | $profile['module']['static']['web'] = true; 246 | $profile['module']['static']['basedir'] = '{path.static}'; 247 | 248 | 249 | /** 250 | * tinyphp-ui 前端库设置 251 | * 252 | * module.tinyphp-ui.enabled 开启 253 | * true 开启前确认是否通过composer/框架加载,引入了tinyphporg/tinyphp-ui模块 254 | * 255 | * module.tinyphp-ui.public_path 在前端源码展示的公共路径、 256 | * 257 | * 根目录下的绝对路径 /tinyphp-ui 258 | * 包含域名的绝对路径 比如cdn域名, demo.xxx.com/tinyphp-ui/ 259 | * 260 | * module.tinyphp-ui.inject 261 | * 是否自动将ui库的公共路径,注入到html源码 262 | * 仅支持engine = template时 263 | * 264 | * module.tinyphp-ui.helper 265 | * ui前端库在view注册的助手类 266 | * message 提示消息体 267 | * pagination 分页 268 | * 269 | * module.tinyphp-ui.template_dirname 270 | * UI库的视图模板路径 271 | * 272 | * module.tinyphp-ui.dev_enabled 是否开启UI调试 273 | * 必须在tinyphp-ui 运行npm run dev后开启调试模式 274 | * 275 | * module.tinyphp-ui.dev_public_path 276 | * 调试库在前端展现的URL 相对于view.public_path的路径 277 | * 278 | * module.tinyphp-ui.dev_event_listener 279 | * 开启调试后的监听事件类 280 | * 281 | * module.tinyphp-ui.assigns array 282 | * 预设的配置变量注入到视图模板内 283 | * example: ui 即寻找tinyphp-ui.config内的ui节点,与application.config的ui节点合并,并以$ui注入到视图变量 284 | */ 285 | $profile['module']['tinyphp-ui']['enabled'] = true; 286 | $profile['module']['tinyphp-ui']['public_path'] = '/static/tinyphp-ui/'; 287 | $profile['module']['tinyphp-ui']['inject'] = true; 288 | 289 | // UI前端模块的开发设置 可选 290 | $profile['module']['tinyphp-ui']['dev']['enabled'] = false; 291 | $profile['module']['tinyphp-ui']['dev']['dev_public_path'] = "http://127.0.0.1:8080/"; 292 | 293 | // 将预设配置的变量注入到视图模板 294 | $profile['module']['tinyphp-ui']['assigns'] = ['ui']; 295 | 296 | return $profile; 297 | ?> -------------------------------------------------------------------------------- /application/views/cache/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/application/views/cache/.keepgit -------------------------------------------------------------------------------- /application/views/compile/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/application/views/compile/.keepgit -------------------------------------------------------------------------------- /application/views/config/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/application/views/config/.keepgit -------------------------------------------------------------------------------- /application/views/templates/default/main/index.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | TinyPHP Framework V2.0.0 4 | 5 | 6 |

Hello World!

7 |
查看demo
8 | 9 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tinyphporg/tinyphp", 3 | "description": "A lightweight PHP MVC framework for Full Stack Developer/一款面向PHP全栈工程师的轻量级高性能MVC PHP框架。", 4 | "type": "project", 5 | "minimum-stability": "stable", 6 | "require": { 7 | "php": ">= 7.3.0", 8 | "tinyphporg/tinyphp-framework": ">= 2.0.0", 9 | "tinyphporg/tinyphp-ui": ">= 2.0.0" 10 | }, 11 | "license": "Apache-2.0", 12 | "version": "2.0.0", 13 | "author": { 14 | "name": "Da.Jin", 15 | "email": "da.jin@tinyphp.org" 16 | }, 17 | "scripts": { 18 | "post-update-cmd": "php public/index.php --debug /debug/clear" 19 | }, 20 | "autoload": { 21 | }, 22 | "extra" : {} 23 | } 24 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | run(); -------------------------------------------------------------------------------- /resources/nginx/tinyphp.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | server_name demo.tinyphp.org; 4 | index index.php index.html index.htm ; 5 | root ../../public; 6 | 7 | location ~ .*\.php(/.*)? 8 | { 9 | fastcgi_pass 127.0.0.1:9000; 10 | fastcgi_index index.php; 11 | include fastcgi.conf; 12 | } 13 | 14 | #location /status { 15 | #stub_status on; 16 | #access_log off; 17 | #} 18 | 19 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 20 | { 21 | expires 30d; 22 | } 23 | 24 | location ~ .*\.(js|css)?$ 25 | { 26 | expires 12h; 27 | } 28 | access_log /data/log/openresty/access_127.0.0.1.log access; 29 | } 30 | -------------------------------------------------------------------------------- /resources/sql/tinyphp-boostrap.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/resources/sql/tinyphp-boostrap.sql -------------------------------------------------------------------------------- /resources/tools/tinyphp-daemon.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # chkconfig: 2345 55 25 3 | # Description: Startup script for service on CentOS 7 4 | 5 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 6 | 7 | #PHP BIN文件 8 | BIN_FILE='/usr/bin/php' 9 | 10 | #服务名称 11 | SERVICE_DAEMON_ID='tinyphp-daemon' 12 | 13 | #服务入口文件 绝对路径 14 | SERVICE_INDEX_FILE='/data/tiny/tinyphp/demo/public/index.php' 15 | 16 | #CMDLINE 17 | DAEMON_CMD_LINE="$BIN_FILE $SERVICE_INDEX_FILE --id=$SERVICE_DAEMON_ID --daemon=" 18 | 19 | #start 20 | do_start() { 21 | ${DAEMON_CMD_LINE}start 22 | if [ $? -eq 0 ];then 23 | echo -e " Staring $SERVICE_DAEMON_ID \033[49;32;1m [ OK ] \033[0m" 24 | fi 25 | } 26 | 27 | #stop 28 | do_stop() { 29 | ${DAEMON_CMD_LINE}stop 30 | if [ $? -eq 0 ];then 31 | echo -e " Stopping $SERVICE_DAEMON_ID \033[49;32;1m [ OK ] \033[0m" 32 | fi 33 | } 34 | 35 | case "$1" in 36 | start) 37 | echo "Starting service_$SERVICE_DAEMON_ID:" 38 | do_start 39 | ;; 40 | stop) 41 | echo "Stopping service_$SERVICE_DAEMON_ID:" 42 | do_stop 43 | ;; 44 | restart) 45 | echo "Restarting service_$SERVICE_NAME:" 46 | do_stop 47 | sleep 3 48 | do_start 49 | ;; 50 | *) 51 | $DAEMON_CMD_LINE -h 52 | exit 3 53 | ;; 54 | 55 | esac 56 | exit 0 -------------------------------------------------------------------------------- /var/cache/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/var/cache/.keepgit -------------------------------------------------------------------------------- /var/log/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/var/log/.keepgit -------------------------------------------------------------------------------- /var/pid/.keepgit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tinyphporg/tinyphp/5a196e8614a362cc891f9580cab5d35d018481b4/var/pid/.keepgit --------------------------------------------------------------------------------