I'm a student kind of new in programming. I was doing college homework with PHP, and got these errors trying to include a controller:
Warning: require_once(../models/teams.model.php): Failed to open stream: No such file or directory in F:\xampp\htdocs\FACULTAD\FORMULA 1 - TPE\app\controllers\teams.controller.php on line 3
Fatal error: Uncaught Error: Failed opening required '../models/teams.model.php' (include_path='F:\xampp\php\pear\PEAR') in F:\xampp\htdocs\FACULTAD\FORMULA 1 - TPE\app\controllers\teams.controller.php:3 Stack trace: #0 F:\xampp\htdocs\FACULTAD\FORMULA 1 - TPE\router.php(15): require_once() #1 {main} thrown in F:\xampp\htdocs\FACULTAD\FORMULA 1 - TPE\app\controllers\teams.controller.php on line 3
(I thinnk some errors are not PEAR related)
I already tried some solutions from different forums, but nothing worked. Tried uninstalling XAMPP and reinstalling a new version, modified the php.ini file with the right path, tried something with a go-pear.php...
I don't know much about these things, so I don't want to modify files without knowing what I'm doing.
Here's the code. It is incomplete and has errors because I focused on solving the PEAR thing, rather than finish coding the router, controllers, etc.
<?php //ROUTER...
define('BASE_URL', '//'.$_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] dirname($_SERVER['PHP_SELF']).'/');
require_once 'app/controllers/teams.controller.php';
require_once 'app/controllers/index.controller.php';
$action = 'home';
if (!empty($_GET['action'])) {
$action = $_GET['action'];
}
$params = explode('/', $action);
switch ($params[0]) {
case 'home':
$indexController->home();
break;
case 'teams':
$teamID = null;
if (isset($params[1])) $teamID = $params[1];
$teamsController->getTeams($teamID);
break;
default:
echo('404 Page not found ;)');
break;
}
<?php //CONTROLLER...
require_once '../models/teams.model.php';
require_once '../views/teams.view.php';
class teamsController {
private $model;
private $view;
public function __construct() {
$this->model = new teamsModel;
$this->view = new teamsView;
}
function getTeams($teamID) {
if ($teamID == null) { //SI ES NULO, MUESTRA TODAS LAS ESCUDERÍAS
$allTeams = $this->model->getAllTeams(); //PIDE TODAS LAS ESCUDERÍAS AL MODEL
$this->model->showAllTeams($allTeams); //MANDA LOS DATOS AL VIEW
}
else {
$teamData = $this->model->getSelectedTeam($teamID); //PIDE LA ESCUDERÍA SELECCIONADA AL MODEL
$this->view->showSelectedTeam($teamData); //MANDA LOS DATOS AL VIEW
}
}
}
If anyone could help me with this, it would be awesome. I need to fix this as soon as possible.