「wamp-server」でphpを使用してMVCの概念を実行しようとしています
ローカル ディレクトリには、alto-router パッケージと routes.php ファイルを使用した基本的なルーティング用の index.php ページがあります。
<?php
$router->map('GET','/test', 'Acme\Controllers\PageController@test' ,'test');
composer.json ファイルは次のとおりです。
{
"name": "eren/eren",
"authors": [
{
"name": "Eren Ardahan",
"email": "???@???.com"
}
],
"require": {
"filp/whoops": "^1.1",
"altorouter/altorouter": "1.1.0"
},
"autoload":{
"psr-4":{"Acme\\":"src/"}
}
}
PageController.php は
<?php namespace Acme\Controllers;
use Acme\Testing\Test;
class PageController
{
public function test(){
include(__DIR__ . "/../../views/test.php");
//---Deleted lines
$test = new Test;
$test -> test();
/---
}
}
acme ディレクトリの Test.php は次のとおりです。
<?php namespace Acme\Testing;
class Test{
public function test(){
echo "Working";
}
}
そして、ビューディレクトリのtest.phpは上にあります.そして、PageController.phpでコメントされた2行を削除すると動作します
<?php
echo "TEST PAGE <br>";
しかし、この行にはエラーがあります:
クラス 'Acme\Testing\Test' が見つかりません..