1 Star 1 Fork 0

阿债 / hack-igniter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

hack-igniter

A example project extends of CodeIgniter v3.x

https://azhai.gitbook.io/hack-igniter/

安装

要求php v5.4及以上版本。

下载最新版本代码,解压并进入目录。

运行下面的命令(需要安装有 composer ),安装依赖包和开发依赖包。

composer install

配置

开发环境的配置依然在 application/config/development 下

第一次务必修改 constants.php 中的网址和 database.php 中的数据库连接

生成Model

设置好数据库连接后,回到安装目录(即 application 再往上一层目录),执行

php index.php gen model     #生成Model文件
php index.php gen fake      #写入演示数据

自动生成所有表的 Model 文件,放入数据库连接为名的子目录中,并且关联对应 Mixin 。

控制器流程

按照 CodeIgniter 规范,访问网址会被对应到“模块/控制器/方法”上,但如果控制中含有

_remap() 方法,则直接执行它。

我们在基础控制器 application/core/MY_Controller.php 中,放置一个 _remap() ,

它的流程是这样:

  • 每个控制有个 context 的属性,类型为 array 。
  • 如果对应的方法是私有或者保护方法,直接返回 404 错误,当前请求结束。
  • 首先执行 initialize() 方法,返回结果作为 context 一部分。同时在这个方法中获取与URL相关的属性,或检查当前用户的权限。
  • 接着执行网址中对应的公开方法,查询数据库等操作在这里实现,其结果也是 context 的一部分。
  • 最后执行 finalize()输出,会先找到对应模板文件,再用 context 中数据渲染模板。

进一步阅读

查看其他

MIT License Copyright (c) 2013 Ryan Liu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A example project extends of CodeIgniter v3.x 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/azhai/hack-igniter.git
git@gitee.com:azhai/hack-igniter.git
azhai
hack-igniter
hack-igniter
master

搜索帮助

14c37bed 8189591 565d56ea 8189591