This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validate(array $data, string $key, $rules) | |
{ | |
if (is_string($rules)) { | |
$rules = explode('|', $rules); | |
} | |
$normalizeRule = function (string $rule) { | |
$normalizedRule = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param mixed $default | |
* @return mixed | |
*/ | |
function array_get(array $config, string $dotPath, $default = null) | |
{ | |
if (key_exists($dotPath, $config)) { | |
return $config[$dotPath]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class app | |
{ | |
/** | |
* @var array | |
*/ | |
protected $app = [ | |
'routes' => [], | |
'groups' => [], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function lang($phrase, $lang = 'tr') | |
{ | |
$phrase = explode('.', $phrase); | |
$file = array_shift($phrase); | |
$phrase = implode('.', $phrase); | |
$path = __DIR__ . "/languages/$lang/$file.php"; | |
if (is_file($path)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// istek foo.com/?/post/view/5 | |
$qs = $_SERVER['QUERY_STRING']; // /post/view/5 | |
$qs = explode('/', $qs); // Array ( [0] => [1] => post [2] => view [3] => 5 ) | |
array_shift($qs); // boş olan ilk öğeyi dizeden alıyoruz/siliyoruz | |
print_r($qs); // Array ( [0] => post [1] => view [2] => 5 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function generateNewSlug($slug) | |
{ | |
$newSlug = explode('-', $slug); | |
if (is_numeric(end($newSlug))) { | |
$last = end($newSlug); | |
array_pop($newSlug); | |
array_push($newSlug, ++$last); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post extends Model | |
{ | |
public function nextPost($id) | |
{ | |
$sql = 'SELECT * FROM posts WHERE id > ? ORDER BY id ASC LIMIT 1'; | |
$sth = $this->db->prepare($sql); | |
$sth->execute(array($id)); | |
return $sth->fetch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Models/PostModel.php | |
* Örnek bir model katmanı | |
*/ | |
class PostModel | |
{ | |
public $pdo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Controllers/Home.php | |
* Home Controller'ı | |
*/ | |
class Home | |
{ | |
public function index() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'Controller.php'; | |
$controller = new Controller; |
NewerOlder