Giter VIP home page Giter VIP logo

syx's Introduction

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)

<?php

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:

<?php
$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:

<?php
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.

<html>
 <head>
   <title>Hello World</title>
 </head>
 <body>
   <?php echo $content; ?>
 </body>
</html>

Run the Applicatioin

http://www.yourhostname.com/

Todo list

  • Single module
  • Integrated swoole

QQ Group

QQ Group: 545348293

syx's People

Contributors

persiliao avatar zuozhehao avatar

syx's Issues

php7.2在make的时候出错

错误内容:
/bin/sh /usr/local/src/Syx/libtool --mode=compile cc -I. -I/usr/local/src/Syx -DPHP_ATOM_INC -I/usr/local/src/Syx/include -I/usr/local/src/Syx/main -I/usr/local/src/Syx -I/usr/local/php7/include/php -I/usr/local/php7/include/php/main -I/usr/local/php7/include/php/TSRM -I/usr/local/php7/include/php/Zend -I/usr/local/php7/include/php/ext -I/usr/local/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/Syx/syx.c -o syx.lo
mkdir .libs
cc -I. -I/usr/local/src/Syx -DPHP_ATOM_INC -I/usr/local/src/Syx/include -I/usr/local/src/Syx/main -I/usr/local/src/Syx -I/usr/local/php7/include/php -I/usr/local/php7/include/php/main -I/usr/local/php7/include/php/TSRM -I/usr/local/php7/include/php/Zend -I/usr/local/php7/include/php/ext -I/usr/local/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/Syx/syx.c -fPIC -DPIC -o .libs/syx.o
/bin/sh /usr/local/src/Syx/libtool --mode=compile cc -I. -I/usr/local/src/Syx -DPHP_ATOM_INC -I/usr/local/src/Syx/include -I/usr/local/src/Syx/main -I/usr/local/src/Syx -I/usr/local/php7/include/php -I/usr/local/php7/include/php/main -I/usr/local/php7/include/php/TSRM -I/usr/local/php7/include/php/Zend -I/usr/local/php7/include/php/ext -I/usr/local/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/Syx/syx_application.c -o syx_application.lo
cc -I. -I/usr/local/src/Syx -DPHP_ATOM_INC -I/usr/local/src/Syx/include -I/usr/local/src/Syx/main -I/usr/local/src/Syx -I/usr/local/php7/include/php -I/usr/local/php7/include/php/main -I/usr/local/php7/include/php/TSRM -I/usr/local/php7/include/php/Zend -I/usr/local/php7/include/php/ext -I/usr/local/php7/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/Syx/syx_application.c -fPIC -DPIC -o .libs/syx_application.o
/usr/local/src/Syx/syx_application.c:661: error: ‘ZEND_ACC_CLONE’ undeclared here (not in a function)
make: *** [syx_application.lo] Error 1

具体环境:
PHP 7.2.0 (cli) (built: Mar 17 2018 01:41:13) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
操作:
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make&make install

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.