Vibe.d tutorial
  • Build web apps with Vibe.d
  • Setting up
  • The default hello world app
  • Use your own HTML page
  • Serving other static files
  • Diet templates
  • More template pages
  • Use your own functions
  • Templates for ease of maintenance
  • Using include in templates
  • Responsive layout using CSS Grid
  • A fixed navbar and sticky footer
  • CSS modal dialogues
  • The web interface
  • Setting up MySQL server and tools
  • The schema
  • Setting up MySQL for Vibe.d
  • The EmployeeController class
  • The EmployeeModel class
  • A form for adding a new employee
  • Saving form data into the database
  • Testing the whole thing
  • Listing all the employees
  • Retrieving a record for editing
  • Saving form changes to the database
  • Deleting a record from the database
  • Finding an employee record by name
  • Displaying error messages with _error
  • Authentication and authorization
  • Logging in and authentication
  • Saving the login state to the session
  • Enforcing authorization through the session
  • Logging out
  • All the sources so far
  • A new project
    • The timekeeping system
Powered by GitBook
On this page

Setting up

PreviousBuild web apps with Vibe.dNextThe default hello world app

Last updated 5 months ago

This tutorial uses Windows 10 but you should be fine with another OS you are familiar with, assuming you know the equivalent commands in your system’s shell terminal. We will be using the terminal or command window a lot. The code was originally written in a Linux system then ported to Windows for this tutorial as majority of developers prefer Windows. Linux users easily follow Windows tutorials anyway, which means Linux users are or were Windows users too.

D is a language that compiles to native code. The Vibe.d framework is essentially a set of libraries written in D, which means your code needs to be linked to those libraries and compiled into a native executable. So we need at least a D compiler and a text editor.

Regarding compilers, there are three choices: DMD, GDC and LDC. It is advised that, for development purposes, we use the DMD compiler for its speed of compilation. When we are ready to deploy the final production version, we use one of the other compilers (GDC or LDC) for the runtime speed and optimizations of the binary output. This tutorial uses the DMD compiler so download and install the compiler by heading to

and click on the ‘Download Windows Installer’ button or the one appropriate for your system.

After the installation in Windows 10, you should have new entries in your start menu.

But even if you don’t, just open a terminal or command window.

To test the installation of the DMD compiler, type dmd on the terminal window. If the installation is successful, it will fill the window with help information, like this:

C:\Users\Owner\Downloads>dmd
DMD32 D Compiler v2.100.2-dirty
Copyright (C) 1999-2022 by The D Language Foundation, All Rights Reserved written by Walter Bright
Documentation: https://dlang.org/
Config file: C:\D\dmd2\windows\bin\sc.ini
Usage:
  dmd [<option>...] <file>...
  dmd [<option>...] -run <file> [<arg>...]

And a lot of other messages.

Here are two DMD options you may find helpful:

dmd --help will display the same information.

dmd --version will show you just the DMD compiler version.

The DMD installer comes with the dub package manager. It is the default package manager for D projects and was written by the creator of the Vibe.d framework himself.

To test dub, simply type in your terminal

dub

If you see a message complaining there is no project manifest, you are good.

Another way to test is to type

dub help

or

dub -h

or

dub --help

These will show the dub help information.

To show just the version number, type

dub --version

After the compiler is installed, the next thing we need is a text editor or IDE. You can stick with your favorite IDE/text editor while following this book, but this book will use the ubiquitous and free Visual Studio Code with versions for Windows, MacOS and Linux. If you haven't installed this yet, head to

and choose the installer appropriate for your system. After downloading, run the downloaded file and follow the instructions.

After installation, add the D language extension to VS Code so it can recognize D language code.

Add the D Programming Language (d-code) extension. With this pack, you will have features like syntax highlighting, code-completion and some error flagging.

Now you are ready to build web apps in Vibe.d.

https://code.visualstudio.com/download
https://dlang.org/