Unable to load class in Mini2 framework application

I am creating a PHP application using the Mini2 framework.

https://github.com/panique/mini2

This is a very simple basic MVC framework. In my index.php file, I have to declare various routes, models, etc.

I share the fragment in which I declare the models.

$model = new \Mini\Model\Model($app->config('database'));
$usermodel = new \Mini\Model\User\userModel($app->config('database'));

In my project root ... there are these files

/Mini/Model/Model.php

/Mini/Model/userModel.php

Here is what my Model.php looks like

<?php

namespace Mini\Model;

use PDO;

class Model
{
    private $db;

    function __construct($config)
    {
        // PDO db connection statement preparation
        $dsn = 'mysql:host=' . $config['db_host'] . ';dbname='    . $config['db_name'] . ';port=' . $config['db_port'];

        // note the PDO::FETCH_OBJ, returning object ($result->id) instead of array ($result["id"])
        // @see http://php.net/manual/de/pdo.construct.php
        $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);

        // create new PDO db connection
        $this->db = new PDO($dsn, $config['db_user'], $config['db_pass'], $options);
    }

}

Here is what my userModel.php looks like

<? php


namespace Mini\Model\User;


use PDO;


class userModel
{
    /private $db;


    function __construct($config)
    {
        $dsn = 'mysql:host='. $config['db_host']. ';dbname='. $config['db_name']. ';port='. $config['db_port'];
        $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING);
        $this->db = new PDO($dsn, $config['db_user'], $config['db_pass'], $options);
    }
}

When I launch my web application, I get this error.

enter image description here

Both of my model files are used and declared the same, but only one is available. Only Model.php is available.

I checked the internal files of the Mini2 infrastructure and could not find the file that requires file preloading. Now I am at a loss.

, userModel User inside model.

/Mini/Model/User/userModel.php

enter image description here

php .

+4
1

:

  • /Mini/Model/userModel.php /Mini/Model/UserModel.php
  • Mini\Model\User; Mini\Model;
  • userModel { UserModel {
  • private $db
  • 72 index.php $user = new\Mini\Model\UserModel ($ config)
  • , . Mini\Model\Model index.php, , , .
0

Source: https://habr.com/ru/post/1628627/


All Articles