• Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An everyone can understand PHP framework for web development

项目文件组织(目录结构)

app/
	classes/
	config/
	console/
	controllers/
	models/
	views/
css/
fonts/
js/
deploy.sh
server.sh
index.php

利用 tools/new_app.php 来创建新项目

在你想建立项目的目录底下, 执行:

php <iphp_framework>/tools/new_app.php

这是执行效果:

$APP['NAME']: myfirstapp
$APP['DOMAIN']: localhost
$APP['PHP_FPM.PORT']: 9000

Generate app into: /Users/ideawu/Works/iphp/tmp/myfirstapp ...
Done!

项目部署

进入你的项目源码目录, 然后执行

sh deploy.sh dev
sh server.sh restart

Nginx 配置

默认情况下每一个 App 是独立的域名, 部署完成后, 通过你创建项目时的域名进行访问. 如果 App 是作为别的域名下的某个路径, 那么需要进行下面的配置.

在已配置了 PHP 的情况下, 你只需要简单添加下面的内容到你的 nginx.conf 里, 然后重启 nginx 即可.

location / {
	try_files $uri $uri/ /index.php?$args;
}

这个配置表示以 / 开头的请求都尝试交给 /index.php 处理, 如果请求不对应某个文件(可能产生 404)的话.

如果想把你的项目放在 /my 目录下, 那么配置文件就是这样:

location /my/ {
	try_files $uri $uri/ /my/index.php?$args;
}

不过, 基于安全等考虑, 你还需要配置更多的东西, 具体参考附带的 demo/app/config/nginx.conf 模板.

location / {
	location ~ /(app|logs)/ {
		deny all;
	}
	location ~ \.(sh|sql|conf|key|crt|csr) {
		deny all;
	}
	location ~ \.(gif|png|jpg|ico|svg|css|js|ttf|woff|eot)$ {
	}
	try_files $uri $uri/ /index.php?$args;
}

注意: 如果你的 nginx.conf 没有配置 index index.php;, 请加上.

URL 路由

路由规则

Project URL Path => Controller + View

路由规则用于将一个 URL 路径, 转变为某一个控制器类(Controoler)的某个实例方法(Action)的执行, 以及某一个视图文件的渲染(View). 这个 URL 路径是相对路径, 相对项目的首页, 如项目的首页是 /my/, 那么 /my/a/b/c 的 URL 路径便是 a/b/c.

例子

URL 路径

a/b/c

控制器(Controller)查找顺序

a/b.php
a/b/c.php
a/b/c/index.php

方法(Action)查找

index() 或者 c()

视图(View)查找顺序

a/b/c.tpl.php
a/b/c.tpl.php
a/b/c/index.tpl.php

模板(Layout)查找顺序

模板文件(Layout)用于定义网页的整体框架, 并在其中某个位置加入

<?php _view(); ?>

表示将视图(View)的内容插入此处. 模板文件默认必须是 layout.tpl.php, iphp 首先在视图(View)文件所在的同目录查找该文件, 如果找不到则查找上一级, 直到 views 目录为止.

演示

Path Controller Aaction View Full URL
about about.php AboutController#index about.tpl.php http://localhost/iphp/about
about/us about.php AboutController#us about/us.tpl.php http://localhost/iphp/about/us
about/job about/job.php JobController#index about/job.tpl.php http://localhost/iphp/about/job
api/test api/test.php TestController#index None http://localhost/iphp/api/test

More Repositories

1

ssdb

SSDB - A fast NoSQL database, an alternative to Redis
C++
8,173
star
2

icomet

A C1000K comet/push server built with C++, for web and mobile app
C++
1,522
star
3

Objective-C-RSA

Doing RSA encryption and decryption with Objective-C on iOS
Objective-C
1,151
star
4

c1000k

A tool to test if your OS supports 1 million connections(c1000k/c1m)
C
596
star
5

sim

Simple C++ network server framework
C++
351
star
6

cocoaui

Build adaptive UI for iOS Apps with flow-layout and CSS properties
Objective-C
325
star
7

ssdb-rocks

ssdb with rocksdb, rocksdb client-server support
C++
140
star
8

tftpx

TFTP server and client implementation in C
C
138
star
9

cocoaui-demos

Build Native iOS Apps with Simple HTML+CSS, Flow Layout
Objective-C
97
star
10

ssdb-docs

SSDB documentation source code
HTML
90
star
11

icomet-demos

Demos for icomet server
Java
85
star
12

ssdb-bin

SSDB pre-compiled binary
81
star
13

cpy

Cpy provides you a way to write Python codes in C syntax!
Python
62
star
14

webrtc-demo

WebRTC GIPS C/C++ API demos
C++
57
star
15

rtc

Real-Time Communication Infracture
C++
56
star
16

snappy-ios

The Snappy compression library for iOS
C++
37
star
17

CocoaUIDemo

moved to https://github.com/ideawu/cocoaui-demos
36
star
18

js-lottery

JS网页抽奖工具
HTML
14
star
19

libfast

Simple FIX and FAST protocol implementation
C++
13
star
20

tableview

JavaScript TableView, PagerView, SelectorView
HTML
12
star
21

phpvoip

SIP implement with PHP
PHP
10
star
22

ParallaxScroll

JavaScritp Parallax Scrolling, Swipe guesture
JavaScript
8
star
23

endlessssh

Tunneling SSH over HTTP
Python
8
star
24

pyhttp

Event driven HTTP library for Python
Python
6
star
25

ios_live_streaming

iOS/macOS 视频直播技术框架
Objective-C
6
star
26

manual

常用操作手册
6
star
27

iOSScrollPicker

iOS Scroll Picker
Objective-C
5
star
28

soc

Simpler Objective-C/Standard Objective-C Library
Objective-C
4
star
29

leetcode

C++
3
star
30

fifo_test

Shows how to properly read and write FIFO on Linux
C++
2
star
31

tovi-js

A JavaScript image gallery and HTML slider, with iPhone swipe effect.
CSS
1
star
32

libave

Audio Video Engine Library
C++
1
star