Connecting to a Database

For most web applications, a database backend is an essential component and luckily, PHP Wax makes it super easy to get going.

Inside your app/config folder you'll find a yaml file - config.yml. This is where you can add configuration values for your application.

The settings we are interested in are for the db. You'll notice that in the example file there's three separate settings for the database and these are wrapped inside an environment specific setting. The reason for this is to allow you to have separate setups for development and production environments. Take a look at the sample file:

development:
 db:
  dbtype: mysql  
  host: localhost
  database: app_development
  username: root

test:
  db:
    dbtype: mysql
    host: localhost
    database: app_test
    username: root

production: 
  db: 
    dbtype: mysql
    host: localhost
    database: app_production
    username: app_name
    password: app_secret      

At the moment we're just concerned with our development environment so edit these settings to reflect your local username and password (If you have your password set to blank, simply leave out the line for password).