supernano / skeleton
Supernano框架项目骨架
v1.0.1
2017-08-17 09:28 UTC
Requires
- php: >=5.4.0
- delfimov/supernano: ^2
This package is not auto-updated.
Last update: 2024-09-29 05:07:52 UTC
README
Supernano Skeleton
为Supernano框架提供的基本骨架。
要求
- PHP >= 5.4(尽管,我强烈推荐使用PHP 7)
- Composer
安装
- 打开您喜欢的Shell
- 将工作目录更改为您的web服务器根目录或您想创建新项目的任何位置
- 运行
composer create-project supernano/skeleton my_project_name
- 回答几个问题
- 您的项目将创建在
my_project_name
目录中 - 将开发域名添加到
c:\Windows\System32\drivers\etc\hosts
或/etc/hosts
- 将VirtualHost添加到Apache配置或服务器到Nginx
- 检查
my_project_name\composer.json
- 运行
composer update
如何使用
模板
- 模板存储在
tpl
目录中 tpl/super/layout.php
是您网站的基模板
路由
- 不带
.php
扩展名的模板名称是URL路径的第一部分。 - 允许的模板名称是
/[a-z0-9_-]+/
。 - 默认模板(如空URL路径的请求
http://www.example.com/%60
)是tpl/index.php
。 - 如果请求的模板不存在,将使用
tpl/super/error404.php
代替(“错误404 - 页面未找到”页面)。
假设我们有一个请求类似http://www.example.com/whatever
。
这意味着模板名称是whatever,框架将在tpl/whatever.php
中查找并将其包含在tpl/super/layout.php
文件中。
如果tpl/whatever.php
不存在,将使用tpl/super/error404.php
。
请求http://www.example.com/what/ever
将查找tpl/what.php
,URL路径将存储在$this->request
数组中(在这种情况下为[0 => 'ever']
)。
可用的变量
$this->request
- 包含URL路径请求的数组$this->get
- 类似于GET请求的数组$this->tplPath
- 模板目录的路径$this->template
- 当前模板名称$this->templateFile
- 当前模板文件名