-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from fatkulnurk/dev
Dev
- Loading branch information
Showing
58 changed files
with
3,007 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<phpunit bootstrap="./vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="My Project - TestSuite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
</phpunit> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
include 'vendor\autoload.php'; | ||
|
||
use Mifa\Http\Message\Uri; | ||
|
||
$uri = new Uri('https://user:[email protected]:8080/path/123?q=abc#test'); | ||
//echo $uri->getPath(); | ||
//echo $uri->getQuery(); | ||
echo $uri->getQuery(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
<?php | ||
use Mifa\Routing\RouteCollector; | ||
|
||
use Fatkulnurk\Microframework\Routing\RouteCollector; | ||
|
||
return function (RouteCollector $r) { | ||
$r->addRoute('GET', '/', function (){ | ||
|
||
/** | ||
* Example GET route | ||
* | ||
* @param array $args Route parameters | ||
* | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
$r->addRoute('GET', '/', function ($args) { | ||
// echo "hello"; | ||
// echo "aaaaaaa"; | ||
echo json_encode([ | ||
'a' => 'b' | ||
]); | ||
header('Content-Type: application/json'); | ||
}); | ||
|
||
$r->addRoute('GET', '/home', function ($args, $request, $response) { | ||
echo "aa"; | ||
}); | ||
}; | ||
|
||
$r->addRoute('GET', '/test/{name}', 'Coba::index'); | ||
}; | ||
|
||
// testing handler | ||
class Coba { | ||
public function index() { | ||
echo "Aaaa"; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
//ini_set('memory_limit', '-1'); | ||
require_once "../vendor/autoload.php"; | ||
|
||
use FastRoute\RouteCollector; | ||
use Mifa\App; | ||
|
||
$app = App::getInstance(); | ||
|
||
$dispatcher = $app->routing(function (RouteCollector $r){ | ||
$r->addRoute('GET', '/', function (){ | ||
|
||
}); | ||
}); | ||
// Fetch method and URI from somewhere | ||
$httpMethod = $_SERVER['REQUEST_METHOD']; | ||
$uri = $_SERVER['REQUEST_URI']; | ||
|
||
// Strip query string (?foo=bar) and decode URI | ||
if (false !== $pos = strpos($uri, '?')) { | ||
$uri = substr($uri, 0, $pos); | ||
} | ||
$uri = rawurldecode($uri); | ||
|
||
$routeInfo = $dispatcher->dispatch($httpMethod, $uri); | ||
switch ($routeInfo[0]) { | ||
case FastRoute\Dispatcher::NOT_FOUND: | ||
// ... 404 Not Found | ||
break; | ||
case FastRoute\Dispatcher::METHOD_NOT_ALLOWED: | ||
$allowedMethods = $routeInfo[1]; | ||
// ... 405 Method Not Allowed | ||
break; | ||
case FastRoute\Dispatcher::FOUND: | ||
$handler = $routeInfo[1]; | ||
$vars = $routeInfo[2]; | ||
// ... call $handler with $vars | ||
die("yeah"); | ||
break; | ||
} | ||
|
||
//App::getInstance() | ||
// ->routing(function (RouteCollector $r){ | ||
// $r->addRoute('GET', '/', function (){ | ||
// | ||
// }); | ||
// })->dispatch(); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Mifa\Core; | ||
|
||
class Config | ||
{ | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Fatkulnurk\Microframework\Core; | ||
|
||
trait Singleton | ||
{ | ||
/** | ||
* Berisi Object dari class yang menggunakan trait ini. | ||
* @var self $instance | ||
*/ | ||
private static $instance = null; | ||
|
||
/** | ||
* Pembuatan object singleton | ||
* @return self | ||
*/ | ||
public static function getInstance() | ||
{ | ||
if (self::$instance == null) { | ||
self::$instance = new static(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
namespace Fatkulnurk\Microframework\Enum; | ||
|
||
use MyCLabs\Enum\Enum; | ||
|
||
class DispatchEnum extends Enum | ||
{ | ||
private const NOT_FOUND = 0; | ||
private const FOUND = 1; | ||
private const METHOD_NOT_ALLOWED = 2; | ||
} |
Oops, something went wrong.