2017 © Pedro Peláez
 

project barak

image

gdemir/barak

  • Saturday, April 1, 2017
  • by gdemir
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Barak

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Requirements Packages and Versions

Install

  • Composer

Composer, (*7)

  • Barak
composer create-project gdemir/barak project_name

Configuration Database File (config/database.ini)

[database_configuration]
host  = localhost
user  = root
pass  = barak
name  = BARAK

Run

cd project_name
php -S localhost:9090

and check homepage : http://localhost:9090 and thats all!, (*8)

Releases


Guides

### Simple Usage

request url : /, (*9)

config/routes.php, (*10)

ApplicationRoutes::draw(
  get("/", "home#index")
);

app/controller/HomeController.php, (*11)

class HomeController extends ApplicationController {

  public function index() {
    $this->message = "Hello World";
  }

}

app/views/home/index.php, (*12)

<h1> Home#Index </h1>;
<?= $message; ?>

app/views/layouts/home.php, (*13)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title></title>
</head>
<body>
  <?= $yield; ?>
</body>
</html>

### Router (config/routes.php)

GET

  • Simple

config/routes.php, (*14)

ApplicationRoutes::draw(
  get("/home/index")
);
  • Dynamical Segment

Dinamik route tanımlamalarında "home#index" gibi hedef belirtilmek zorundadır:, (*15)

config/routes.php, (*16)

ApplicationRoutes::draw(
  get("/home/index/:id", "home#index")
);

Dinamik route tanımlamalarında ki "id" gibi parçalara erişim:, (*17)

app/controllers/HomeController.php, (*18)

class HomeController extends ApplicationController {

  public function index() {
    echo $this->id;
  }

}

app/views/home/index.php, (*19)

<h1> Home#Index </h1>;
<?= "id" . $id; ?>

POST

  • Simple

config/routes.php, (*20)

ApplicationRoutes::draw(
  post("/admin/login")
);

app/controllers/AdminController.php, (*21)

class AdminController extends ApplicationController {

  protected $before_actions = [
  ["require_login", "except" => ["login", "logout"]]
  ];

  public function login() {

    if (isset($_SESSION["admin"]))
      return $this->redirect_to("/admin/index");

    if (isset($_POST["username"]) and isset($_POST["password"])) {

      if ($user = User::unique(["username" => $_POST["username"], "password" => md5($_POST["password"])])) {

        $_SESSION["success"] = "Admin sayfasına hoş geldiniz";
        $_SESSION["full_name"] = "$user->first_name $user->last_name";
        $_SESSION["admin"] = $user->id;
        return $this->render("/admin/index");

      } else {

        $_SESSION["danger"] = "Oops! İsminiz veya şifreniz hatalı, belki de bunlardan sadece biri hatalıdır?";

      }
    }

    return $this->render(["layout" => "default"]);
  }

  // public function index() {} // OPTIONAL

  public function logout() {
    if (isset($_SESSION["admin"]))
      session_destroy();
    return $this->redirect_to("/admin/login");
  }

  public function require_login() {
    if (!isset($_SESSION["admin"])) {
      $_SESSION["warning"] = "Lütfen hesabınıza giriş yapın!";
      return $this->redirect_to("/admin/login");
    }
  }
}

app/views/admin/index.php, (*22)

<h1> Admin#Index </h1>;
<?= $_SESSION["full_name"]; ?>

RESOURCE

config/routes.php, (*23)

ApplicationRoutes::draw(
  resource("/users")
);

Aşağıdaki routes kümesini üretir:, (*24)

ApplicationRoutes::draw(
  get("/users/", "users#index"), // all record
  get("/users/create"),          // new record form
  post("users/save"),            // new record save
  get("/users/show"),            // display record
  get("/users/edit"),            // edit record
  post("/users/update"),         // update record
  post("/users/destroy")         // destroy record
);

RESOURCES

config/routes.php, (*25)

ApplicationRoutes::draw(
  resources("/users")
);

Aşağıdaki routes kümesini üretir:, (*26)

ApplicationRoutes::draw(
  get("/users", "users#index"),         // all record
  get("/users/create"),                 // new record form
  post("/users/save"),                  // new record save
  get("/users/show/:id", "users#show"), // display record
  get("/users/edit/:id", "users#edit"), // edit record
  post("/users/update"),                // update record
  post("/users/destroy")                // destroy record
);

SCOPE

Kodları daha derli toplu kullanmak için Route'in Gruplama özelliğidir. Bir PATH altında CONTROLLER ve VIEW dizininin çalışma imkanı sağlar., (*27)

controller: app/controllers/PATH/CONTROLLER.php, (*28)

view : app/views/VIEW/PATH/CONTROLLER/ACTION.php, (*29)

  • Simple

config/routes.php, (*30)

view : app/views/admin/categories/ACTION.php controller : app/controllers/admin/CategoriesController.php, (*31)

ApplicationRoutes::draw(
 scope("/admin",
    resources("/categories")
 )
);

Aşağıdaki routes kümesini üretir:, (*32)

ApplicationRoutes::draw(
  get("/admin/categories",          "categories#index", "/admin"),  // all record
  get("/admin/categories/create",   false,              "/admin"),  // new record form
  post("/admin/categories/save",    false,              "/admin"),  // new record save
  get("/admin/categories/show/:id", "categories#show",  "/admin"),  // display record
  get("/admin/categories/edit/:id", "categories#edit",  "/admin"),  // edit record
  post("/admin/categories/update",  false,              "/admin"),  // update record
  post("/admin/categories/destroy", false,              "/admin"),  // destroy record
);
  • Mix

config/routes.php, (*33)

ApplicationRoutes::draw(
  get("/admin/login"),
  scope("/admin",
    [
    get("/users", "users#index"),
    get("/users/show/:id")
    ],
    resources("/categories"),
    resource("/products")
  );

);

Aşağıdaki routes kümesini üretir:, (*34)

ApplicationRoutes::draw(
  get("/admin/login"),

  get("/admin/users",               "users#index",      "/admin"),  // all record
  get("/admin/users/show/:id",      false,              "/admin"),  // display record

  get("/admin/categories",          "categories#index", "/admin"),  // all record
  get("/admin/categories/create",   false,              "/admin"),  // new record form
  post("/admin/categories/save",    false,              "/admin"),  // new record save
  get("/admin/categories/show/:id", "categories#show",  "/admin"),  // display record
  get("/admin/categories/edit/:id", "categories#edit",  "/admin"),  // edit record
  post("/admin/categories/update",  false,              "/admin"),  // update record
  post("/admin/categories/destroy", false,              "/admin"),  // destroy record

  get("/admin/products",           "products#index",    "/admin"),  // all record
  get("/admin/products/create",     false,              "/admin"),  // new record form
  post("/admin/products/save",      false,              "/admin"),  // new record save
  get("/admin/products/show",       false,              "/admin"),  // display record
  get("/admin/products/edit",       false,              "/admin"),  // edit record
  post("/admin/products/update",    false,              "/admin"),  // update record
  post("/admin/products/destroy",   false,              "/admin")   // destroy record
);

ROOT

config/routes.php, (*35)

ApplicationRoutes::draw(
  root("home#index")
);

Aşağıdaki routes kümesini üretir:, (*36)

ApplicationRoutes::draw(
  get("/", "home#index"),
);

### Controller (app/controller/*.php)

Her config/routes.php içerisinde tanımlanan get işlemi için app/controller/*.php dosyası içerisinde fonksiyon tanımlamak zorunlu değildir, tanımlanırsa bir değişken yükü/yükleri controller içinde $this->KEY şeklinde tanımlanırsa ilgili yönlenen sayfada $KEY şeklinde veriye erişebilir. Her config/routes.php içerisinde tanımlanan post için ilgili app/controller/*.php dosyası içerisinde fonksiyon tanımlamak zorunludur., (*37)

  • Render

layout : app/views/layouts/VIEW.php, (*38)

view : app/views/VIEW/ACTION.php, (*39)

Example, (*40)

class HomeController extends ApplicationController {

  public function index() {
    echo "HomeIndex sayfası öncesi çalışan fonksiyon";

    // DEFAULT LAYOUT: home, VIEW: home, ACTION: index
    $this->render("/home/index"); // like $this->render(["template" => "/home/index"]);

    // DEFAULT LAYOUT: home, VIEW: home, ACTION: show
    $this->render("/home/show"); // like $this->render(["template" => "/home/show"]);

    // DEFAULT LAYOUT: home, VIEW: admin, ACTION: show
    $this->render("/admin/show"); // like $this->render(["template" => "/admin/show"]);

    // Default LAYOUT: home, VIEW: home, ACTION: index
    $this->render(["layout" => "home", "view" => "home", "action" => "index"]); // default render

    // LAYOUT: false, VIEW: home, ACTION: index
    $this->render(["layout" => false]);

    // LAYOUT: home, VIEW: admin, ACTION: index
    $this->render(["view" => "admin", "action" => "index"]);

    // LAYOUT: home, VIEW: admin, ACTION: index
    $this->render(["view" => "admin", "action" => "index"]);

    // LAYOUT: admin, VIEW: home, ACTION: show
    $this->render(["layout" => "admin", "view" => "home", "action" => "show"]);

    // LAYOUT: admin, VIEW: home, ACTION: index
    $this->render(["layout" => "admin", "template" => "home/index"]);

    // LAYOUT: admin, VIEW: home, ACTION: show
    $this->render(["layout" => "admin", "template" => "home/show"]);

    // LAYOUT: false, VIEW: false, ACTION: false
    // only load controller params and get this file
    $this->render(["file" => "/app/views/admin/login.php"]);

    // TODO partial, ayrıca sayfa üzerinde
    // $this->render(["partial" => "home/navbar"]);
  }

}
  • Redirect

request url [/ or /home] redirect to /home/index, (*41)

config/routes.php, (*42)

ApplicationRoutes::draw(
  get("/", "home#home"), // or root("home#home"),
  get("/home", "home#home"),
  get("/home/index"),
);

app/controllers/HomeController.php, (*43)

class HomeController extends ApplicationController {
  public function home() {
    return $this->redirect_to("/home/index");
  }
  public function index() {}
}

app/views/home/index.php, (*44)

<h1>Home#Index</h1>
  • Before Action

Before Action (protected $before_actions) özelliği, app/controller/*.php dosyası içerisinde her çalışacak get/post fonksiyonları için önceden çalışacak fonksiyonları belirtmeye yarayan özelliktir. Özelliğin etkisini ayarlamak için aşağıdaki 3 şekilde kullanılabilir:, (*45)

  1. except anahtarı ile nerelerde çalışmayacağını, (*46)

  2. only anahtarı ile nerelerde çalışacağını, (*47)

  3. Anahtar yok ise her yerde çalışacağını, (*48)

class HomeController extends ApplicationController {

  protected $before_actions = [
    ["login", "except" => ["login", "index"]],
    ["notice_clear", "only" => ["index"]],
    ["every_time"]
  ];

  public function index() {
    echo "HomeIndex : Anasayfa (bu işlem için login fonksiyonu çalışmaz, notice_clear ve every_time çalışır)";
  }

  public function login() {
    echo "Home#Login : Her işlem öncesi login oluyoruz. (get/post için /home/login, /home/index hariç)";
  }

  public function notice_clear() {
    echo "Home#NoticeClear : Duyular silindi. (get/post için sadece /home/index'de çalışır)";
  }

  public function every_time() {
    echo "Home#EveryTime : Her zaman get/post öncesi çalışırım.";
  }
  • After Action

After Action (protected $after_actions) özelliği, app/controller/*.php dosyası içerisinde her çalışacak get/post fonksiyonları için sonradan çalışacak fonksiyonları belirtmeye yarayan özelliktir. Özelliğin etkisini ayarlamak için aşağıdaki 3 şekilde kullanılabilir:, (*49)

  1. except anahtarı ile nerelerde çalışmayacağını, (*50)

  2. only anahtarı ile nerelerde çalışacağını, (*51)

  3. Anahtar yok ise her yerde çalışacağını, (*52)

#TODO, (*53)

  • Simple

config/routes.php, (*54)

ApplicationRoutes::draw(
  get("/admin/home"),
  get("/admin/login"),
  post("/admin/login")
);

app/controller/AdminController.php, (*55)

class AdminController extends ApplicationController {

  protected $before_actions = [
  ["require_login", "except" => ["login", "logout"]]
  ];

  public function login() {

    if (isset($_SESSION["admin"]))
      return $this->redirect_to("/admin/index");

    if (isset($_POST["username"]) and isset($_POST["password"])) {

      if ($user = User::unique(["username" => $_POST["username"], "password" => md5($_POST["password"])])) {

        $_SESSION["success"] = "Admin sayfasına hoş geldiniz";
        $_SESSION["full_name"] = "$user->first_name $user->last_name";
        $_SESSION["admin"] = $user->id;
        return $this->render("/admin/index");

      } else {

        $_SESSION["danger"] = "Oops! İsminiz veya şifreniz hatalı, belki de bunlardan sadece biri hatalıdır?";

      }
    }

    return $this->render(["layout" => "default"]);
  }

  // public function index() {} // OPTIONAL

  public function logout() {
    if (isset($_SESSION["admin"]))
      session_destroy();
    return $this->redirect_to("/admin/login");
  }

  public function require_login() {
    if (!isset($_SESSION["admin"])) {
      $_SESSION["warning"] = "Lütfen hesabınıza giriş yapın!";
      return $this->redirect_to("/admin/login");
    }
  }
}

app/views/admin/login.php, (*56)

<div class="row">
  <div class="col-xs-3">
    <img src="/app/assets/img/default.png" class="img-thumbnail" />
  </div>
  <div class="col-xs-9">
    <form class="login-form" action="/admin/login" accept-charset="UTF-8" method="post">
      <input type="text" placeholder="Kullanıcı Adı" class="form-control" size="50" name="username" id="username" />
      <input type="password" placeholder="Parola" class="form-control" size="50" name="password" id="password" />
      <button type="submit" class="btn btn-primary" style="width:100%">SİSTEME GİRİŞ</button>
    </form>
  </div>
</div>

app/views/admin/home.php, (*57)

<h1> Admin#Home </h1>

app/views/layouts/admin.php, (*58)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title></title>
</head>
<body>
  <?= $yield; ?>
</body>
</html>

### Views (app/views/DIRECTORY/*.php)

Her get işlemi için config/routes.php de yönlendirilen controller ve action adlarını alarak, app/views/CONTROLLER/ACTION.php html sayfası app/views/layouts/CONTROLLER.php içerisine <?= $yield; ?> değişken kısmına gömülür ve görüntülenir., (*59)

app/views/DIRECTORY/*.php, (*60)

<h1> Hello World </h1>

app/views/layouts/DIRECTORY.php, (*61)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title></title>
</head>
<body>
  <?= $yield; ?>
</body>
</html>

### Model (app/models/TABLE.php)

app/models/TABLE.php example: app/models/User.php, (*62)

class User extends ApplicationModel {

  public function full_name() {
    return $this->first_name . " " . $this->last_name;
  }

}
$user = User::find(1);
echo $user->full_name();
  • Public Access Functions

save, destroy, delete_all, select, where, or_where, joins, order, group, limit, take, pluck, count, (*63)

  • Static Access Functions

draft, load, create, unique, find, find_all, all, first, last, exists, delete, update, (*64)

CREATE ( new, create )

new, (*65)

// Ör. 1:

$user = User::draft();
$user->first_name = "Gökhan";
$user->save();
print_r($user); // otomatik id alır

// Ör. 2:

$user = User::draft(["first_name" => "Gökhan"])->save();
print_r($user); // otomatik id alır

create, (*66)

``` php $user = User::create(["first_name" => "Gökhan"]); print_r($user);, (*67)


#### READ ( `load`, `select`, `where`, `or_where`, `order`, `group`, `limit`, `take`, `pluck`, `count`, `joins`, `find`, `find_all`, `all`, `first`, `last` ) > `load` ```php $users = User::load()->take(); foreach ($users as $user) echo $user->first_name;

where, (*68)

operators: =, !=, >, <, >=, <=, (*69)

$users = User::load()->where("first_name", "Gökhan")->take();
$users = User::load()->where("first_name", "Gökhan", "=")->take();
// SELECT * FROM user WHERE first_name = 'Gökhan';

$users = User::load()->where("age", 25, "<>")->take();
// SELECT * FROM user WHERE age <> 25;

$users = User::load()->where("age", 25, ">")->take();
// SELECT * FROM user WHERE age > 25;

$users = User::load()->where("age", 25, "<")->take();
// SELECT * FROM user WHERE age < 25;

$users = User::load()->where("age", 25, ">=")->take();
// SELECT * FROM user WHERE age >= 25;

$users = User::load()->where("age", 25, "<=")->take();
// SELECT * FROM user WHERE age <= 25;

operators: IS NULL, IS NOT NULL, (*70)

$users = User::load()->where("email", NULL)->take();
$users = User::load()->where("email", "IS NULL")->take();
// SELECT * FROM user WHERE email IS NULL;
$users = User::load()->where("email", "IS NOT NULL")->take();
// SELECT * FROM user WHERE email IS NOT NULL;

operators: LIKE, NOT LIKE, (*71)

$users = User::load()->where("email", "%.com.tr", "LIKE")->take();
// SELECT * FROM user WHERE email LIKE '%.com.tr';
$users = User::load()->where("email", "%.com.tr", "NOT LIKE")->take();
// SELECT * FROM user WHERE email NOT LIKE '%.com.tr';

operators: IN, NOT IN, (*72)

$users = User::load()->where("id", [1, 2, 3], "IN")->take();
// SELECT * FROM user WHERE id IN (1, 2, 3);
$users = User::load()->where("id", [1, 2, 3], "NOT IN")->take();
// SELECT * FROM user WHERE id NOT IN (1, 2, 3)

operators: BETWEEN, NOT BETWEEN, (*73)

$users = User::load()->where("created_at", ["2016-12-01", "2016-13-01"], "BETWEEN")->take();
// SELECT * FROM user WHERE created_at BETWEEN "2016-12-01" AND "2016-13-01";
$users = User::load()->where("created_at", ["2016-12-01", "2016-13-01"], "NOT BETWEEN")->take();
// SELECT * FROM user WHERE created_at NOT BETWEEN "2016-12-01" AND "2016-13-01";

or_where, (*74)

only logic key: OR, (*75)

// where($field, $value, $mark, "OR")
$users = User::load()->where("first_name", "Gökhan")->or_where("last_name", "Demir")->take();
$users = User::load()->where("first_name", "Gökhan", "=", "AND")->where("last_name", "Demir", "=", "OR")->take();
// SELECT * FROM user WHERE first_name = 'Gökhan' OR last_name = 'Demir';

select, where, order, group, limit, take, (*76)

$users = User::load()
           ->where("first_name", "Gökhan")
           ->select("first_name")
           ->order("id")
           ->limit(10)
           ->take();

foreach ($users as $user)
  echo $user->first_name;

pluck, (*77)

// Ör. 1:
$user_ids = User::load()->pluck("id");
print_r($user_ids);
// [1, 2, 3, 4, 66, 677, 678]


// Ör. 2:

$user_firstnames = User::load()->pluck("first_name");
print_r($user_firstnames);
// ["Gökhan", "Göktuğ", "Gökçe", "Gökay", "Atilla", "Altay", "Tarkan", "Başbuğ", "Ülkü"]

count, (*78)

// Ör. 1:
echo User::load()->count();
// 12


// Ör. 2:

echo User::load()->where("first_name", "Gökhan")->count();
// 5

joins, (*79)

// Department ["id", "name"], User ["id", "department_id", "first_name"], "Address" ["id", "user_id", "content"]

$department = Department::load()
                ->joins(["User", "Address"])
                ->where("User.id", 1)
                ->select("User.first_name, Department.name, Address.content")
                ->limit(1)
                ->take();
print_r($department);

unique, (*80)

$user = User::unique(["username" => "gdemir", "password" => "123456"]);
echo $user->first_name;

find, (*81)

$user = User::find(1);
echo $user->first_name;

find_all, (*82)

$users = User::find_all([1, 2, 3]);
foreach ($users as $user)
  echo $user->first_name;

all, (*83)

$users = User::all();
foreach ($users as $user)
  echo $user->first_name;

first, (*84)

// Ör. 1:

$user = User::first();
echo $user->first_name;

// Ör. 2:
$users = User::first(10);
foreach ($users as $user)
  echo $user->first_name;

last, (*85)

// Ör. 1:

$user = User::last();
  echo $user->first_name;

// Ör. 2:

$users = User::last(10);
foreach ($users as $user)
  echo $user->first_name;

exists, (*86)

echo User::exists(1) ? "kayit var" : "kayit yok";

UPDATE ( save, update )

save, (*87)

// Ör. 1:

$user = User::unique(["username" => "gdemir", "password" => "123456"]);
$user = User::find(1);
$user = User::first();
$user = User::last();
$user->first_name = "Gökhan";
$user->save()
print_r($user);

// Ör. 2:

$users = User::find_all([1, 2, 3]);
$users = User::load()->take();
$users = User::all();
$users = User::load()
           ->where("first_name", "Gökhan")
           ->select("first_name")
           ->order("id")
           ->limit(10)
           ->take();
$users = User::first(10);
foreach ($users as $user) {
  $user->first_name = "Göktuğ";
  $user->save();
}

update, (*88)

// Ör. 1:

User::update(1, ["first_name" => "Gökhan", "last_name" => "Demir"]);

// Ör. 2:

$users = User::find_all([1, 2, 3]);
$users = User::load()->take();
$users = User::all();
$users = User::load()
           ->where("first_name", "Gökhan")
           ->select("first_name")
           ->order("id")
           ->limit(10)
           ->take();
foreach ($users as $user)
  User::update($user->id, ["first_name" => "Göktuğ", "last_name" => "Demir"]);

DELETE ( destroy, delete, delete_all )

destroy, (*89)


$user = User::unique(["username" => "gdemir", "password" => "123456"]); $user = User::find(1); $user = User::first(); $user = User::last(); $user->destroy();

delete, (*90)

User::delete(1);

delete_all, (*91)

User::load()->delete_all();
User::load()->where("first_name", "Gökhan")->delete_all();
User::load()->where("first_name", "Gökhan")->limit(10)->delete_all();
User::load()->limit(10)->delete_all();

Dependencies ($BELONG_TABLE->OWNER_TABLE, $OWNER_TABLE->all_of_BELONG_TABLE)

$BELONG_TABLE->OWNER_TABLE, (*92)

// Department ["id", "name"]
// User ["id", "department_id", "first_name", "last_name"]
// Book ["id", "user_id", "name"]

// Department
// [1, "Bilgisayar Mühendisliği"]
// [2, "Makine Mühendisliği"]

// User
// [1, 1, "Gökhan", "Demir"]
// [2, 1, "Göktuğ", "Demir"]
// [3, 2, "Göksen", "Demir"]

// Book
// [1, 1, "Barak Türkmenlerinin Tarihi"]
// [2, 1, "Oğuz Boyu"]
// [3, 3, "Almila"]

// Ör. 1:

$book = Book::find(1);
// [1, 1, "Barak Türkmenlerinin Tarihi"]

print_r($book->user);
// [1, 1, "Gökhan", "Demir"]

print_r($book->user->department);
// [1, "Bilgisayar Mühendisliği"]

echo "$book->user->department->name $book->user->first_name  $book->name";
// "Bilgisayar Mühendisliği Gökhan Barak Türkmenlerinin Tarihi"

$OWNER_TABLE->all_of_BELONG_TABLE, (*93)

// User ["id", "department_id", "first_name", "last_name"]
// Book ["id", "user_id", "name"]

// User
// [1, 1, "Gökhan", "Demir"]
// [2, 1, "Göktuğ", "Demir"]
// [3, 2, "Göksen", "Demir"]

// Book
// [1, 1, "Barak Türkmenlerinin Tarihi"]
// [2, 1, "Oğuz Boyu"]
// [3, 2, "Kımız"]
// [4, 3, "Almila"]

$user = User::find(1);
$books = $user->all_of_book;
foreach ($books as $book)
  echo $book->name;

### Configurations (config/database.ini, config/application.ini)

config/database.ini (database configuration file), (*94)

[database_configuration]
host  = localhost
user  = root
pass  = barak
name  = BARAK

config/application.ini (application configuration file), (*95)

[app_configuration]
display_errors = true
time_zone      = Europe/Istanbul

Seeds (db/seeds.php)

Proje başlamadan önce ilk çalıştırılacak dosyadır., (*96)

db/seeds.php (database seeds file), (*97)

if (User::load()->count() == 0) {
User::create(["first_name" => "Gökhan", "last_name" => "Demir", "username" => "gdemir",  "password" => "123456"]);
User::create(["first_name" => "Gökçe",  "last_name" => "Demir", "username" => "gcdemir", "password" => "123456"]);
User::create(["first_name" => "Göktuğ", "last_name" => "Demir", "username" => "gtdemir", "password" => "123456"]);
User::create(["first_name" => "Atilla", "last_name" => "Demir", "username" => "ademir",  "password" => "123456"]);
}

Trailer

BarakTurkmens BarakTurkmens#İskan BarakTurkmens#YanıkKerem BarakTurkmens#MürselBey BarakTurkmens#VeledBey BarakTurkmens#VeledBey2, (*98)

Sources

License

Barak is released under the MIT License., (*99)

The Versions

01/04 2017

v1.0.0

1.0.0.0

  Sources   Download

22/02 2017

dev-master

9999999-dev https://github.com/gdemir/barak

Barak MVC Framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework barak turkmen

19/02 2017

v2.0.0

2.0.0.0 https://github.com/gdemir/barak

Barak MVC Framework

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework barak turkmen

26/01 2017

v1.1.0

1.1.0.0 https://github.com/gdemir/barak

Barak MVC Framework

  Sources   Download

MIT

The Requires

 

framework barak turkmen