Welcome Guest, Not a member yet? Register   Sign In
can't create instance of a model class in models from controller class
#1

Abstract of problem is this :

in app/controllers dir,  i have  files such as Home.php , News.php with class names matching

From  index method of Home class i can do this :

class Home extends BaseController
{
    public function index()
   
    {
       
   
    $handle= new News();
    $handle->index();


i.e I can create an instance of a class located in /app/Controllers from another class , the file  holding it also in controllers.

With a simple class in Models directory however i get : 

Class 'Andy\UserModel' not found

the Andy comes from me trying namespace global permutations.


the dir with codeigniter is called CI and is located at /var/www/htdocs apache on slackware

echo of APPPATH gives : /var/www/htdocs/CI/app/

i've checked permissions of files in /var/www/htdocs/CI/app/Models/ and they are at least read for all

set up on apache (i don't know if this has anything to do with it) is via virtual hosts eg

<VirtualHost 127.0.0.2:80>
  <Directory /var/www/htdocs/CI/public>
 Options Indexes   FollowSymLinks
Require all granted
AllowOverride All
</Directory>
ServerAdmin [email protected]
  ServerName CI.org
    DocumentRoot /var/www/htdocs/CI/public/
    ServerAlias www.CI.org
    #ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
    #C<ustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>

using http://127.0.0.2/  home page works , a route a added works and from a controller i can access from a sqlite3 database. I was moving function of database data access from controller to model when found problem.

Any ideas?
Reply


Messages In This Thread
can't create instance of a model class in models from controller class - by captain-sensible - 11-11-2019, 12:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB