-
Notifications
You must be signed in to change notification settings - Fork 1
Getting started Guide
Before you can use Rubik you need to make sure that development environment is up-to-date and ensure that everything is setup correctly. Let's go throught the requirements of Rubik first.
Rubik Framework is written using Go programming language but you'll need Go runtime to execute your Rubik server. The
official Go installation guide provides you with a step by step instruction to install Go
.
Testing your Go installation:
# this command outputs the version of Go runtime that you have installed
go version
Rubik CLI helps you in being productive and accomplish your tasks with ease. It has some really nice advantages over normal execution that is discussed here.
Shell:
curl https://rubik.ashishshekar.com/install | sh
Note: okrubik is not supported for Windows yet. Although, you can download and build the CLI for your platform from this repository (instructions provided inside README.md). It is not tested with this alpha release.
Thie CLI will be downloaded and installed under $HOME/.rubik/bin
folder. You need to add this path to your
bash_profile
or it's equivalents:
# example
nano ~/.bash_profile
# add the below line to the end of the file
export PATH="$HOME/.rubik/bin:$PATH"
Now let's check if the installation was successful. Run:
okrubik
# Welcome to Rubik Command-Line Manager use --help for help text
You have just set-up your development environment like a boss. You are ready to Go!!
.
okrubik help
# Rubik is an efficient web framework for Go that encapsulates
# common tasks and functions and provides ease of REST API development.
# Complete documentation is available at https://rubikorg.github.io
# Usage:
# okrubik [flags]
# okrubik [command]
# Available Commands:
# create Create a new rubik project
# exec Execute a rubik command defined inside rubik.toml under [x] object
# gen Generates project code for your Rubik server
# help Help about any command
# run Runs the app created under this workspace
# upgrade Upgrade the project dependencies or upgrade self
# Flags:
# -h, --help help for okrubik
# Use "okrubik [command] --help" for more information about a command.
You'll see the list and short description about Rubik commands. Let's create a helloworld
Rubik project by running:
okrubik create
This will ask you questions such as name
, module-name
, port
of the Rubik server and a
confirmation like so:
# ? Project Name? helloworld
# ? Init go.mod with path? helloworld
# ? Default server port? 4000
# ? Confirm? Yes
# creating helloworld/cmd/server/routers/import.go
# creating helloworld/cmd/server/routers/index/controller.go
# creating helloworld/cmd/server/routers/index/route.go
# creating helloworld/cmd/server/config/decl.go
# creating helloworld/cmd/server/config/default.toml
# creating helloworld/cmd/server/main.go
# creating helloworld/cmd/server/templates/index.html
# creating helloworld/README.md
# creating helloworld/rubik.toml
# creating helloworld/cmd/server/static/main.css
# creating go.mod
# tidying up |> helloworld
# Done! Run command: okrubik run
You'll have a new directory called helloworld
now and will consists of Rubik project files.
Let's run the server by running:
okrubik run -a server
Now let's visit localhost:4000. Wew! Our Rubik project is all set-up in just under a minute. This is a great start!