基于c扩展框架php,基于Swoole,Yaf开发的C扩展框架

Syx - base of Yaf 3.0.4

Requirement

PHP 7.0 +

Install

Compile Syx in Linux

$ /path/to/phpize

$ ./configure --with-php-config=/path/to/php-config

$ make && make install

Tutorial

layout

A classic Application directory layout:

- .htaccess // Rewrite rules

+ public

| - index.php // Application entry

| + css

| + js

| + img

+ conf

| - application.ini // Configure

- application/

- Bootstrap.php // Bootstrap

+ index // index module

+ controller

- Index.php // Default controller

+ model

- User.php // Model

+ view

|+ index

- index.html // View template for default controller

+ plugin

- System.php

+ library

DocumentRoot

you should set DocumentRoot to application/public, thus only the public folder can be accessed by user

index.php

index.php in the public directory is the only way in of the application, you should rewrite all request to it(you can use .htaccess in Apache+php mod)

define("APPLICATION_PATH", dirname(dirname(__FILE__)));

$app = new Syx\Application(APPLICATION_PATH . "/conf/application.ini");

$app->bootstrap() //call bootstrap methods defined in Bootstrap.php

->run();

Rewrite rules

Apache

#.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule .* index.php

Nginx

server {

listen ****;

server_name domain.com;

root document_root;

index index.php index.html index.htm;

if (!-e $request_filename) {

rewrite ^/(.*) /index.php/$1 last;

}

}

Lighttpd

$HTTP["host"] =~ "(www.)?domain.com$" {

url.rewrite = (

"^/(.+)/?$" => "/index.php/$1",

)

}

application.ini

application.ini is the application config file

[product]

;CONSTANTS is supported

application.directory = APPLICATION_PATH "/application/"

alternatively, you can use a PHP array instead:

$config = array(

"application" => array(

"directory" => application_path . "/application/",

"namespace" => 'app' // application default namespace

),

);

$app = new Syx\Application($config);

....

default controller

In Syx, the default controller is named Index:

namespace app\index\controller;

class Index extends Syx\ControllerAbstract {

// default action name

public function indexAction() {

$this->getView()->content = "Hello World";

}

}

view script

The view script for default controller and default action is in the application/index/view/index/index.html, Syx provides a simple view engineer called "Syx\View\Simple", which supported the view template written by PHP.

Hello World

Run the Applicatioin

Todo list

Single module

Integrated swoole

QQ Group

QQ Group: 545348293

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值