1、加载静态资源路径文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
大于5.0.4版本可以直接使用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
__ROOT__ :项目目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
__STATIC__ :项目目录下的static目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
__JS__ :项目目录下的static/js目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
__css__:项目目录下的static/css目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
我们可以使用view模板打印这些常量的具体路径文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Insert title here</title>
- </head>
- <body>
- __ROOT__<br>
- __STATIC__<br>
- __JS__<br>
- __CSS__<br>
- </body>
- </html>
页面输出如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
- /
- /projectname/public/static
- /projectname/public/static/js
- /projectname/public/static/css
打开application文件夹下的config文件,可根据你自己需要自定义资源常量,定义好后常量就可以在模板文件中使用常量了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
例如:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
- <?php
- return [
- 'view_replace_str' => [
- '__PUBLIC__'=>'../public/static/admin',
- '__ROOT__' => '/',
- '__APP__' => 'app/admin/',
- ]
- ];
2、预定义常量文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
预定义常量是指系统内置定义好的常量,不会随着环境的变化而变化,包括:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
EXT 类库文件后缀(.php)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
THINK_VERSION 框架版本号文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
3、路径常量文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
系统和应用的路径常量用于系统默认的目录规范,可以通过重新定义改变,如果不希望定制目录,这些常量一般不需要更改。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
DS 当前系统的目录分隔符文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
THINK_PATH 框架系统目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
ROOT_PATH 框架应用根目录文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
APP_PATH 应用目录(默认为application)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
CONF_PATH 配置目录(默认为APP_PATH)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
LIB_PATH 系统类库目录(默认为 THINK_PATH.'library/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
CORE_PATH 系统核心类库目录 (默认为 LIB_PATH.'think/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
TRAIT_PATH 系统trait目录(默认为 LIB_PATH.'traits/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
EXTEND_PATH 扩展类库目录(默认为 ROOT_PATH . 'extend/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
VENDOR_PATH 第三方类库目录(默认为 ROOT_PATH . 'vendor/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
RUNTIME_PATH 应用运行时目录(默认为 ROOT_PATH.'runtime/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
LOG_PATH 应用日志目录 (默认为 RUNTIME_PATH.'log/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
CACHE_PATH 项目模板缓存目录(默认为 RUNTIME_PATH.'cache/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
TEMP_PATH 应用缓存目录(默认为 RUNTIME_PATH.'temp/')文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
4、系统常量文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
系统常量会随着开发环境的改变或者设置的改变而产生变化。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
IS_WIN 是否属于Windows 环境文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
IS_CLI 是否属于命令行模式文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
THINK_START_TIME 开始运行时间(时间戳)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
THINK_START_MEM 开始运行时候的内存占用文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html
ENV_PREFIX 环境变量配置前缀文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/7667.html