Skip to content

Commit

Permalink
Added an example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jukka Svahn committed May 14, 2013
1 parent bd3b315 commit 650e031
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions examples/Basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Examples;
use Rah\Danpu\Dump;
use Rah\Danpu\Config;
use Rah\Danpu\Export;
use Rah\Danpu\Import;

// Include Composer's autoloader. You can also use
// any other PSR-0 compatible autoloader. Just point
// the autoloader to the '../src' directory with the
// namespace of Rah\Danpu.

include '../vendor/autoload.php';

// Creates a new instance of Rah\Danpu\Dump.

$dump = new Dump;
$dump
->file(__DIR__ . '/file.sql')
->dsn('mysql:dbname=database;host=localhost')
->user('username')
->pass('password')
->tmp('/tmp');

// Exports the database.

new Export($dump);

// Imports the database.

new Import($dump);

// Alternatively you could create a personalized config instance
// by extending.

class MyAppConfig extends Config
{
public $file = 'file.sql';
public $dsn = 'mysql:dbname=database;host=localhost';
public $user = 'username';
public $pass = 'password';
public $tmp = '/tmp';
}

// Export again using MyAppConfig.

new Export(new MyAppConfig);

// Or import.

new Import(new MyAppConfig);

0 comments on commit 650e031

Please sign in to comment.