Skip to content

Commit 64e8c55

Browse files
committed
first commit
0 parents  commit 64e8c55

20 files changed

+683
-0
lines changed

.htaccess

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<IfModule mod_rewrite.c>
2+
RewriteEngine On
3+
RewriteCond %{REQUEST_FILENAME} !-d
4+
RewriteCond %{REQUEST_FILENAME} !-f
5+
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
6+
</IfModule>

action.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
class action {
4+
public function run() {
5+
$GET = filter_input(INPUT_GET, 'url');
6+
$params = explode('/', $GET);
7+
$fileName = array_shift($params);
8+
$filePath = __DIR__ . '/models/' . $fileName . '.php';
9+
$className = $fileName . '_action';
10+
11+
if ($fileName && file_exists($filePath)) {
12+
require __DIR__ . '/models/' . $fileName . '.php';
13+
$app = new $className();
14+
extract($app->handle($params)); //viewに変数をアサイン
15+
require __DIR__ . '/views/' . $fileName . '.php';
16+
} else if(!$fileName || !file_exists($filePath)){
17+
require __DIR__ . '/models/index.php';
18+
$app = new index_action();
19+
extract($app->handle($params)); //viewに変数をアサイン
20+
require __DIR__ . '/views/index.php';
21+
}
22+
}
23+
}
24+

composer.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"autoload": {
3+
"psr-4": {
4+
"Models\\": "models/",
5+
"Views\\": "views/",
6+
"Controllers\\": "controllers/"
7+
}
8+
}
9+
}
10+
11+

composer.phar

1.84 MB
Binary file not shown.

controllers/action.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
class action {
4+
public function run() {
5+
$GET = filter_input(INPUT_GET, 'url');
6+
$params = explode('/', $GET);
7+
$fileName = array_shift($params);
8+
$filePath = './models/' . $fileName . '.php';
9+
$className = $fileName . '_action';
10+
11+
if ($fileName && file_exists($filePath)) {
12+
require './models/' . $fileName . '.php';
13+
$app = new $className();
14+
extract($app->handle($params)); //viewに変数をアサイン
15+
require './views/' . $fileName . '.php';
16+
} else if(!$fileName || !file_exists($filePath)){
17+
require './models/index.php';
18+
$app = new index_action();
19+
extract($app->handle($params)); //viewに変数をアサイン
20+
require './views/index.php';
21+
}
22+
}
23+
}

index.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
require __DIR__ . '/action.php';
4+
5+
$app = new action();
6+
$app->run();

models/blog.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
class blog_action{
4+
function handle($params){
5+
return array(
6+
'title'=>'Hello World! (blog)',
7+
'h1'=>'Hello World! (blog)'
8+
);
9+
}
10+
}

models/index.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
class index_action {
4+
function handle($params) {
5+
return array(
6+
'title'=>'Hello World! (index)',
7+
'h1'=>'Hello World! (index)'
8+
);
9+
}
10+
}

text.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
4+
参考にしたサイト
5+
6+
PHP10行で作る超シンプルフレームワーク
7+
http://choilog.com/katty0324/blog/6

vendor/autoload.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer/autoload_real.php';
6+
7+
return ComposerAutoloaderInit19164ec464b2f491dbd710edad138ac3::getLoader();

0 commit comments

Comments
 (0)