The aim of this document/project is to introduce Vapor, a framework for Swift & Web project. The project is a simple hello-world and will evolve to introduce new concepts. Do not search a coherence or utility for this project.
Vapor is a Swift-3-language based framework. So you need to have:
- Mac OS (works on Sierra)
- XCode 8 (for Swift 3 stuff)
- Homebrew (for Vapor installation)
- Knowledge of website/web-programming concepts
- Knowledge of Swift (version 3 is better)
Install vapor with Homebrew:
brew install vapor/tap/toolbox
curl -sL toolbox.vapor.sh | bash
Ensure that installation is completed with:
vapor --help
Homebrew may be out of date. Use :
brew update
First be patient. If the installation phase seems to be stuck, ensure it by using
top
If nothing seems to happen, try killing the installation with Ctrl-C and ensure the installation complete with
vapor --help
vapor new HelloWorld
cd HelloWorld
vapor xcode
- Open *.xcodeproj file
- Select App scheme
- Click on Build button
- You should see this sentence in terminal: starting at 0.0.0.0:8080
- Try with your favorite browser (http://localhost:8080)
The ORM used by Vapor is Fluent. https://github.com/vapor/fluent
There are multiple database drivers used by Fluent. These are some of them:
- MySQL (https://github.com/vapor/mysql https://github.com/vapor/mysql-driver https://github.com/vapor/mysql-provider)
- SQLite (https://github.com/vapor/sqlite https://github.com/vapor/sqlite-driver https://github.com/vapor/sqlite-provider)
- MongoDB (https://github.com/vapor/mongo-driver https://github.com/vapor/mongo-provider)
- PostgresSQL (https://github.com/vapor/postgresql, https://github.com/vapor/postgresql-driver, https://github.com/vapor/postgresql-provider)