Giter Site home page Giter Site logo

is00hcw / vanilla Goto Github PK

View Code? Open in Web Editor NEW

This project forked from idevz/vanilla

0.0 3.0 0.0 2.01 MB

An OpenResty Lua MVC Web Framework

Home Page: http://idevz.github.io/vanilla/

License: MIT License

Shell 0.80% Makefile 1.18% CSS 1.23% HTML 6.81% C 7.62% Lua 54.05% Perl 28.32%

vanilla's Introduction

Vanilla / (香草中文文档) / OSC Git

Join the chat at https://gitter.im/idevz/vanilla Vanilla is An OpenResty Lua MVC Web Framework.

Vanilla

MailList

Install

There are two ways to install:

  • Make (recommended way)
  • Luarocks

Tips of make install:

Vanilla support many configuration options, many of those option have default value.

You can use default installation but if your enviroment values different from which vanilla default, please config it with yours. Especially the --openresty-path option. you should make sure it's point to your turely OpenResty install path. You can run command ./configure --help to learn how to use those options.

Below is the installation of a simple example:

./configure --prefix=/usr/local/vanilla --openresty-path=/usr/local/openresty

make install

Tips of luarocks install:

You can use luarocks to install vanilla, but three point should be clear:

  1. Your luarocks should install with lua5.1.x because of the compatibility problems in ABIs between Lua and Luajit.
  2. parameter NGX_PATH will be disabled in the nginx.conf.
  3. make sure that command nginx is in your environment PATH.

Vanilla usage

Vanilla CMDs

Vanilla provide two commands vanilla, and vanilla-console.

  • vanilla is for application building, service start, stop and so on.
  • vanilla-console is an interactive command line, you can use it for debugging, testing, Lua learning...

Run vanilla in command line, you can find command vanilla provide three options.

vanilla
Vanilla v0.1.0-rc3, A MVC web framework for Lua powered by OpenResty.

Usage: vanilla COMMAND [ARGS] [OPTIONS]

The available vanilla commands are:
 new [name]             Create a new Vanilla application
 start                  Starts the Vanilla server
 stop                   Stops the Vanilla server
 restart				First Stops and then Starts the Vanilla servers

Options:
 --trace                Shows additional logs

Building up an application skeleton

vanilla new app_name
cd app_name
vanilla start [--trace]     -- default running in development environment.
-- under bash on linux
VA_ENV=production vanilla start [--trace]  -- add VA_ENV to set the running environment.
-- under tcsh on BSD
setenv VA_ENV production ; vanilla start [--trace]  -- add VA_ENV to set the running environment.

Directory Structure

 /Users/zj-git/app_name/ tree ./
./
├── application
│   ├── bootstrap.lua --application boot
│   ├── controllers
│   │   ├── error.lua --application error handling, dealing with corresponding business under this path error
│   │   └── index.lua --vanilla hello world
│   ├── library       --local libs
│   ├── models 
│   │   ├── dao       --data handles for DB, APIs
│   │   │   └── table.lua
│   │   └── service   --encapsulations of DAOs
│   │       └── user.lua
│   ├── nginx         --openresy http phases
│   │   └── init.lua  --init_by_lua demo
│   ├── plugins
│   └── views         --one to one correspondence to controllers
│       ├── error     --error handle view layout
│       │   └── error.html
│       └── index     --index controller views
│           └── index.html
├── config
│   ├── application.lua --app basic configuration such as router,initialization settings...
│   ├── errors.lua    --app error conf
│   ├── nginx.conf    --nginx.conf skeleton
│   ├── nginx.lua     --nginx settings like lua_code_cache.
│   ├── waf-regs      --WAF rules
│   │   ├── args
│   │   ├── cookie
│   │   ├── post
│   │   ├── url
│   │   ├── user-agent
│   │   └── whiteurl
│   └── waf.lua       --app WAF config
├── logs
│   └── hack          --attack logs, keep path can be write
├── pub               --app content_by_lua_file path
    └── index.lua     --entrance file

IndexController Demo

local IndexController = {}

function IndexController:index()
    local view = self:getView()
    local p = {}
    p['vanilla'] = 'Welcome To Vanilla...'
    p['zhoujing'] = 'Power by Openresty'
    view:assign(p)
    return view:display()
end

return IndexController
Template demo (views/index/index.html)
<!DOCTYPE html>
<html>
<body>
  <img src="http://m1.sinaimg.cn/maxwidth.300/m1.sinaimg.cn/120d7329960e19cf073f264751e8d959_2043_2241.png">
  <h1><a href = 'https://github.com/idevz/vanilla'>{{vanilla}}</a></h1><h5>{{zhoujing}}</h5>
</body>
</html>

Why Vanilla

To answer this question, we just need to see what did Openresty and Vanilla have done.

Openresty

  • Provides processing HTTP requests a full set of the overall solution
  • Opened up a new way for Nginx module development, we can use Lua to deal with Web requests
  • Formed an increasingly perfect ecology, the ecological covers all aspects of high-performance Web services

Vanilla

  • Implement a Web development routine debugging, error handling, exception handling
  • Implement complete processing of the request and plug-in mechanism, support routing protocol, the template engine configuration
  • Integration, encapsulates a series of Web development commonly used tool set, class library (cookies, application firewall, etc.)
  • Features easy to use and extend
  • Support different environment (development, test, online)
  • Focus on the business development, not any about nginx nor OpenResty
  • Based on OpenResty, have all the good qualities of OpenResty
  • Automated, Nginx instruction set of configuration management
  • More reasonable use Openresty encapsulation of request processing Phase

Community

QQ Groups&&WeChat public no.

  • Openresty/Vanilla Dev:205773855 (Vanilla panel discussion related topics)
  • Openresty:34782325(Discuss OpenResty and all kinds of advanced technology)
  • WeChat public no. of Vanilla Dev:Vanilla-OpenResty(Vanilla related information, document push)

QQ

vanilla's People

Contributors

gitter-badger avatar idevz avatar lhmwzy avatar

Watchers

 avatar  avatar  avatar

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.