Vapor 3 Beta 1 发布



  • 准备工作:

    • Swift版本:4.1(目前为dev阶段,本篇使用的是 swift-DEVELOPMENT-SNAPSHOT-2018-02-07-a 版本,建议使用 swiftenv 来管理Swift多版本)

    • Vapor Toolbox:3.1.3(具体安装步骤可参考 教程


    开始

    初始化Vapor项目

    vapor new VaporBetaDemo --branch=beta
    

    将会输出以下内容:

    $ vapor new VaporBetaDemo --branch=beta
    Cloning Template [Done]
    Updating Package Name [Done]
    Initializing git repository [Done]
    
                                           **
                                         **~~**
                                       **~~~~~~**
                                     **~~~~~~~~~~**
                                   **~~~~~~~~~~~~~~**
                                 **~~~~~~~~~~~~~~~~~~**
                               **~~~~~~~~~~~~~~~~~~~~~~**
                              **~~~~~~~~~~~~~~~~~~~~~~~~**
                             **~~~~~~~~~~~~~~~~~~~~~~~~~~**
                            **~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
                            **~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
                            **~~~~~~~~~~~~~~~~~~~~~++++~~~**
                             **~~~~~~~~~~~~~~~~~~~++++~~~**
                              ***~~~~~~~~~~~~~~~++++~~~***
                                ****~~~~~~~~~~++++~~****
                                   *****~~~~~~~~~*****
                                      *************
                             
                             _       __    ___   ___   ___
                            \ \  /  / /\  | |_) / / \ | |_)
                             \_\/  /_/--\ |_|   \_\_/ |_| \
                               a web framework for Swift
    
                       Project "VaporBetaDemo" has been created.
                Type `cd VaporBetaDemo` to enter the project directory.
                Use `vapor cloud deploy` to host your project for free!
                                         Enjoy!
    

    进入到项目目录:

    cd VaporBetaDemo/
    

    创建 .swift-version文件,内容为 4.1-DEVELOPMENT-SNAPSHOT-2018-02-07-a

    $ touch .swift-version
    vi .swift-version
    

    开始build project:

    swift build
    

    将会输出以下内容:

    $ swift build
    Fetching https://github.com/vapor/fluent.git
    Fetching https://github.com/vapor/service.git
    Fetching https://github.com/vapor/tls.git
    Fetching https://github.com/vapor/template-kit.git
    Fetching https://github.com/vapor/async.git
    Fetching https://github.com/vapor/console.git
    Fetching https://github.com/vapor/vapor.git
    Fetching https://github.com/vapor/core.git
    Fetching https://github.com/vapor/crypto.git
    Fetching https://github.com/vapor/database-kit.git
    Fetching https://github.com/vapor/engine.git
    Fetching https://github.com/vapor/sockets.git
    Cloning https://github.com/vapor/tls.git
    Resolving https://github.com/vapor/tls.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/console.git
    Resolving https://github.com/vapor/console.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/core.git
    Resolving https://github.com/vapor/core.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/database-kit.git
    Resolving https://github.com/vapor/database-kit.git at 1.0.0-beta.1
    Cloning https://github.com/vapor/sockets.git
    Resolving https://github.com/vapor/sockets.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/crypto.git
    Resolving https://github.com/vapor/crypto.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/service.git
    Resolving https://github.com/vapor/service.git at 1.0.0-beta.1
    Cloning https://github.com/vapor/template-kit.git
    Resolving https://github.com/vapor/template-kit.git at 1.0.0-beta.1
    Cloning https://github.com/vapor/fluent.git
    Resolving https://github.com/vapor/fluent.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/async.git
    Resolving https://github.com/vapor/async.git at 1.0.0-beta.1
    Cloning https://github.com/vapor/engine.git
    Resolving https://github.com/vapor/engine.git at 3.0.0-beta.1
    Cloning https://github.com/vapor/vapor.git
    Resolving https://github.com/vapor/vapor.git at 3.0.0-beta.1
    Compile CHTTP http_parser.c
    Compile CSQLite sqlite3.c
    Compile Swift Module 'Bits' (5 sources)
    Compile Swift Module 'COperatingSystem' (1 sources)
    Compile Swift Module 'Debugging' (6 sources)
    Compile Swift Module 'Logging' (3 sources)
    Compile Swift Module 'SQL' (21 sources)
    Compile Swift Module 'Async' (45 sources)
    Compile Swift Module 'Service' (17 sources)
    Compile Swift Module 'TCP' (12 sources)
    Compile Swift Module 'Crypto' (29 sources)
    Compile Swift Module 'CodableKit' (24 sources)
    Compile Swift Module 'Console' (21 sources)
    Compile Swift Module 'DatabaseKit' (17 sources)
    Compile Swift Module 'TLS' (6 sources)
    Compile Swift Module 'ServerSecurity' (1 sources)
    Compile Swift Module 'HTTP' (36 sources)
    Compile Swift Module 'AppleTLS' (5 sources)
    Compile Swift Module 'Validation' (15 sources)
    Compile Swift Module 'SQLite' (22 sources)
    Compile Swift Module 'TemplateKit' (38 sources)
    Compile Swift Module 'Command' (11 sources)
    Compile Swift Module 'Fluent' (47 sources)
    Compile Swift Module 'WebSocket' (9 sources)
    Compile Swift Module 'Multipart' (5 sources)
    Compile Swift Module 'FormURLEncoded' (13 sources)
    Compile Swift Module 'FluentSQL' (13 sources)
    Compile Swift Module 'FluentSQLite' (9 sources)
    Compile Swift Module 'Routing' (9 sources)
    Compile Swift Module 'Vapor' (62 sources)
    Compile Swift Module 'App' (5 sources)
    Compile Swift Module 'Run' (1 sources)
    Linking ./.build/x86_64-apple-macosx10.10/debug/Run
    

    执行程序 ./.build/x86_64-apple-macosx10.10/debug/Run

    将会输出以下内容:

    $ ./.build/x86_64-apple-macosx10.10/debug/Run
    Migrating sqlite DB
    Migrations complete
    Server starting on http://localhost:8080
    

    浏览器访问 http://localhost:8080/hello,将会显示相应的内容,大功告成。


Log in to reply