PHPackages                             cnsyao/cnsphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. cnsyao/cnsphp

ActiveLibrary[Framework](/categories/framework)

cnsyao/cnsphp
=============

a simple php mvc framework, based on smarty

018PHP

Since Jan 26Pushed 8y agoCompare

[ Source](https://github.com/cnsphp/CnsPHP)[ Packagist](https://packagist.org/packages/cnsyao/cnsphp)[ RSS](/packages/cnsyao-cnsphp/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

```
.Install
1) composar
   ubuntu)
       apt-get install curl
       apt-get install git
       apt-get install php7.0 php7.0-json php7.0-mbstring php7.0-intl php7.0-fpm php-memcached
       curl -sS https://getcomposer.org/installer | php
       mv composer.phar /usr/local/bin/composer

       useradd -s /bin/bash -d /home/user user

       mkdir -p /home/user
       chown -R user:user /home/user

       su - user
       composer  create-project cnsyao/cnsphp -s dev

    CentOS/Redhat)
       ...

2) git
   git clone https://github.com/cnsphp/CnsPHP.git

3) download
   wget https://github.com/cnsphp/CnsPHP/archive/master.zip

////////////////////////////////////////////////////////////////////////////////

.nginx
#/etc/nginx/sites-enabled/cnsphp.yiyaozg.com
server {
    listen 80;
    server_name cnsphp.yiyaozg.com;
    root /data/webs/cnsphp.yiyaozg.com/public;
    index index.htm index.html index.php ;

    error_log /var/log/nginx/error.log;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    charset utf-8;

    add_header X-Frame-Options "SAMEORIGN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    index index.html index.php;

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    location ~ \.php$ {
        include    fastcgi_params;
        fastcgi_index index.php;
        fastcgi_pass    127.0.0.1:9006;
        add_header Access-Control-Allow-Origin *;
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,QCTKA,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
    }
}

.php
;/etc/php/7.0/fpm/pool.d/cnsphp.yiyaozg.com.conf
[cnsphp]
;prefix = /data/webs/cnsphp.yiyaozg.com/public
;chroot = $prefix
;chdir = /
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen = 127.0.0.1:9006
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
php_value[upload_max_filesize]= 100m
php_value[post_max_size] = 100m
php_value[max_execution_time] = 1800
php_flag[display_errors] = on
php_value[date.timezone] = asia/shanghai
;php_value[session.save_handler] = memcached
;php_value[session.save_path] = tcp://127.0.0.1:11211

# CnsPHP
  a simple php web framework based on smarty ^_^

# Structure
/cnsphp.yiyaozg.com
├── Application
│   ├── config.inc.php (配置文件)
│   ├── route.inc.php
│   ├── init.inc.php
│   ├── Controller (主要业务编程区)
│   │   ├── AppController.php (Application用户Controller的基类)
│   │   ├── Common
│   │   │     └── CommonController.php
│   │   └─ Admin
│   │   │    ├── IndexController.php
│   │   │    ├── UserController.php
│   │   │    ├── ...
│   │   │    └── WxpayController.php
│   │   └─ User
│   │       ├── IndexController.php
│   │       ├── UserController.php
│   │       ├── ...
│   │       └── WxpayController.php
│   │
│   ├── Model
│   │    ├── AppModel.php
│   │    └── Front
│   │         └── IndexModel.php
│   ├── View
│   │     ├── cache
│   │     ├── compile
│   │     │    ├── 117e3ee986632ea32414f51c36f33c9b36cd144e_0.file.index.html.php
│   │     │    └── f9aa2f04ca5ef71405378acc0b07b8b087648838_0.file.index.html.php
│   │     ├── config
│   │     └── html
│   │         └── job
│   │             ├── p
│   │             │   └── center.html
│   │             └── u
│   │                 ├── login.html
│   │                 └── register.html
│   └── Common
│     ├── CnsAntiXSS.php
│     ├── CnsMail.php
│     ├── CnsSMS.php
│     ├── CnsToken.php
│     ├── token.php
│     ├── third
│     │   ├── alimail
│     │   │   ├── AliMail.php
│     │   │   └── aliyun
│     │   │       ├── aliyun-php-sdk-alidns
│     │   │       ...
│     │   │       ├── aliyun-php-sdk-green
│     │   │       └── README.md
│     │   ├── alipay
│     │   │   ├── config.php
│     │   │   ...
│     │   │   └── return_url.php
│     │   ├── sms
│     │   │   ├── smsapi.class.php
│     │   │   └── SMSCN.php
│     │   └── wxpay
│     │       ├── cert
│     │       ├── index.php
│     │        ..
│     │       └── logs
│     │           └── 2017-09-17.log
│     └── vendor
│         ├── firebase
│         │   └── php-jwt
│         ├── ircmaxell
│         │   └── password-compat
│         ├── paragonie
│         │   └── random_compat
│         └── voku
│            └─anti-xs
├── CnsPHP (基本不用修改)
│   ├── Common
│   │   ├── CheckCode.php
│   │   ├── CnsMemcached.php
│   │   ├── cookie.txt
│   │   ├── FileCache.php
│   │   ├── File.php
│   │   ├── Ftp.php
│   │   ├── Img.php
│   │   ├── ImgUploadEffect.php
│   │   ├── Net.php
│   │   ├── QRCode.php
│   │   ├── Spider.php
│   │   ├── String.php
│   │   ├── Str.php
│   │   └── SVG.php
│   ├── Controller
│   │   ├── Auth.php
│   │   ├── Controller.php
│   │   └── Route.php
│   ├── Model
│   │   └── Model.php
│   ├── Route.php
│   └── View
│       ├── Autoloader.php
│       ├── debug.tpl
│       ├── plugins
│       ├── SmartyBC.class.php
│       ├── Smarty.class.php
│       └── sysplugins
│           ├── smarty_cacheresource_custom.php
│           ├ ....
│           ├── smarty_undefined_variable.php
│           └── smarty_variable.php
├── Docs
│   └──API.docx
└── public
    ├── css
    ├── images
    ├── index.php
    ├── js
    │   └── jquery.form.js
    └── uploads

# Example
   http://www.a.com/module/controller/method/arg1/val1/arg2/val2/arg3/val3

   1)
   http://www.a.com/admin/user/info/a/b/c/d/e/f

   Controller/Admin/User.php
      public function Info($args,$post,$get) {
          ...
      }

   2)
   http://www.a.com/admin/user/get-info/a/b/c/d/e/f

   Controller/Admin/User.php
      public function GetInfo($args,$post,$get) {
           $a=$args['a'];
           $x=$post['x'];
           $y=$get['y'];
      }

   3)
   http://www.a.com/blog/user-admin/get-info/a/b/c/d/e/f

   Controller/Blog/UserAdmin.php
      public function GetInfo($args,$post,$get) {
           ...
      }

# Controller and Smarty TPL
