RedBeanPHP\Facade::setup PHP Method

setup() public static method

Kickstarts redbean for you. This method should be called before you start using RedBean. The Setup() method can be called without any arguments, in this case it will try to create a SQLite database in /tmp called red.db (this only works on UNIX-like systems).
public static setup ( string $dsn = NULL, string $username = NULL, string $password = NULL, boolean $frozen = FALSE ) : ToolBox
$dsn string Database connection string
$username string Username for database
$password string Password for database
$frozen boolean TRUE if you want to setup in frozen mode
return ToolBox
    public static function setup($dsn = NULL, $username = NULL, $password = NULL, $frozen = FALSE)
    {
        if (is_null($dsn)) {
            $dsn = 'sqlite:/' . sys_get_temp_dir() . '/red.db';
        }
        self::addDatabase('default', $dsn, $username, $password, $frozen);
        self::selectDatabase('default');
        return self::$toolbox;
    }

Usage Example

<?php

ini_set('max_execution_time', 0);
require 'vendor/autoload.php';
require_once 'vendor/fzaninotto/faker/src/autoload.php';
$faker = Faker\Factory::create('fr_FR');
use RedBeanPHP\Facade as R;
R::setup('mysql:host=localhost;dbname=gsb_cost_managment', 'root', 'pwsio');
R::exec('CREATE VIEW visitor AS SELECT * FROM gsb_human_ressources.employee WHERE employee.job_id=3');
$status = R::dispense('status');
$status->libelle = 'Créée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Clôturée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Validée';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Mise en paiement';
R::store($status);
$status = R::dispense('status');
$status->libelle = 'Remboursée';
R::store($status);
for ($i = 0; $i < 12960; $i++) {
    $cost_sheet = R::dispense('costsheet');
    $cost_sheet->month = $faker->month;
    $cost_sheet->visitor = R::findOne('visitor', 'id=?', [$faker->numberBetween($min = 1, $max = 540)]);
    $cost_sheet->status = R::findOne('status', 'id=?', [$faker->numberBetween($min = 1, $max = 5)]);
    $cost_sheet->justification_number = $faker->randomDigitNotNull;
    $cost_sheet->valid_amount = $faker->randomNumber($nbDigits = 3);
All Usage Examples Of RedBeanPHP\Facade::setup