postanowiłem w końcu ogarnąć MVC na przykładzie http://lukasz-socha.pl/php/mvc-w-praktyce-...artykulow-cz-1/ i na dzień dobry dostaje w pysk.
Myślę sobie dobra pozbądźmy się composera
index.php:
require_once 'config.php'; //$loader = include DIR_VENDOR.'autoload.php'; <-- komentuje by nie mieć composera require_once 'config-router.php'; $router = new \Engine\Router\Router('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); //var_dump('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); $router->run(); $file=$router->getFile(); $classController=$router->getClass(); $method=$router->getMethod(); require_once($file); $obj = new $classController(); $obj->$method();
Niestety tak zedytowany plik daje mi:
Fatal error: Class 'Engine\Router\RouteCollection' not found in /home/konto/public_html/config-router.php on line 2
o to config-router.php
<?php $collection = new Engine\Router\RouteCollection(); $collection->add('category/delete', new \Engine\Router\Route( HTTP_SERVER.'kategorie/usun/<id>?', 'file' => DIR_CONTROLLER.'Category.php', 'method' => 'delete', 'class' => '\Controller\Category' ), 'id' => '\d+' ), 'id' => 0 ) )); $collection->add('category/add', new \Engine\Router\Route( HTTP_SERVER.'kategorie/dodaj', 'file' => DIR_CONTROLLER.'Category.php', 'method' => 'add', 'class' => '\Controller\Category' ) )); $collection->add('category/index', new \Engine\Router\Route( HTTP_SERVER.'kategorie', 'file' => DIR_CONTROLLER.'Category.php', 'method' => 'index', 'class' => '\Controller\Category' ) )); $collection->add('article/delete', new \Engine\Router\Route( HTTP_SERVER.'artykuly/usun/<id>?', 'file' => DIR_CONTROLLER.'Article.php', 'method' => 'delete', 'class' => '\Controller\Article' ), 'id' => '\d+' ), 'id' => 0 ) )); $collection->add('article/one', new \Engine\Router\Route( HTTP_SERVER.'artykuly/wyswietl/<id>?', 'file' => DIR_CONTROLLER.'Article.php', 'method' => 'one', 'class' => '\Controller\Article' ), 'id' => '\d+' ), 'id' => 0 ) )); $collection->add('article/add', new \Engine\Router\Route( HTTP_SERVER.'artykuly/dodaj', 'file' => DIR_CONTROLLER.'Article.php', 'method' => 'add', 'class' => '\Controller\Article' ) )); $collection->add('article/index', new \Engine\Router\Route( HTTP_SERVER.'artykuly', 'file' => DIR_CONTROLLER.'Article.php', 'method' => 'index', 'class' => '\Controller\Article' ) )); $collection->add('homepage', new \Engine\Router\Route( HTTP_SERVER.'', 'file' => DIR_CONTROLLER.'Article.php', 'method' => 'index', 'class' => '\Controller\Article' ) )); $router = new \Engine\Router\Router($_SERVER['REQUEST_URI'], $collection); ?>
Drugie pytanie czy to:
$model = new \RacyMind\MVCWPraktyce\Model\Category();
oznacza , że plik powinien się znajdować w katalogach RacyMind > MVCWPraktyce ?
Czy coś to zmieni jak pousuwam z kodu \RacyMind\MVCWPraktyce\