After you've installed haskell,
cabal and yesod (see the other tutorials).
$ yesod init
enter information like project name and database type.
enter the newly created directory:
$ cd <project_name>
edit your database config (i.e. set database username and password and database name(it's ok if the database doesn't exist yet)). If you choose MySQL, do:
$ vim config/mysql.yml
Then create the database itself:
your_password with your root password and
database_name with your database name)
$ mysql -u root -pyour_password -e 'create database database_name default charset utf8;'
Now edit file
config/models and define the models which will be used to create your database structure. An example:
User ident Text password Text Maybe UniqueUser ident deriving Typeable Email email String user UserId Maybe verkey Text Maybe UniqueEmail email Post title String text Text author UserId Maybe date_added UTCTime
Now start the server:
You probably have some errors in the models definitions. Just edit it and save the file and your application will re-compile.
The usual cycle is:
- edit a file
- view server info to see whether there's been errors ( when you start a server using
yesod devel, you'll see lots of info printed to stdout. This is what I call "server info". Info gets updated automatically every time your edit a file)
- fix errors (if present)
Permission denied when running
$ sudo chown $USER ~/.cabal -R
Failed to install mysql bindings (something like mysql-simple-0.2.2.4 depends on mysql-0.1.1.5 which failed to install.)
You need to make sure you have
mysql_config commands installed in your box:
(If on Ubuntu/Debian:)
$ sudo apt-get install mysql-server $ sudo apt-get install libmysqlclient-dev