3

Can anyone tell me what might be the source of this error. I have tried all solutions I found online with no avail. I just installed a cakePHP framework and I am getting this error on index.cpt page...

Error: Fatal error: Class 'AppController' not found in [mypath] on line 2

<?php
class HomeController extends AppController {
     function index() {
     //nothing's here
     }
 }
?>

The above is my code...homeController.php and appController.php are on the same folder

3
  • is [mypath] the place where it should be looking? If it's not looking at the right path, then it's a config issue...if it's looking at the right path but not able to find the class, then you probably named the namespace or the class name incorrectly. Commented Jul 23, 2015 at 21:23
  • 1
    possible duplicate of Fatal error: Class 'AppController' not found Commented Jul 23, 2015 at 21:44
  • 1
    That's btw the first google result... also check book.cakephp.org/2.0/en/getting-started/… Commented Jul 23, 2015 at 21:45

2 Answers 2

4

This solved my problem after many searching

<?php
    namespace App\Controller;
    use App\Controller\AppController;
    class HomeController extends AppController{
        public function index(){

        }
    }
Sign up to request clarification or add additional context in comments.

Comments

0

In my case i was getting

Error: Fatal error: Class 'App\Controller\App\Controller' not found in C:\wamp64\www\CakePHP\src\Controller\TestsController.php on line 5

TestsController.php

<?php
    namespace App\Controller;
    use App\Controller\AppController;

    class TestsController extends App**\**Controller {
        public function index() {
        }
    }
?>

Solution: The error was just a silly typing mistake in extends line. it was a "\", in App\Controller; Using AppController instead of App\Controller has resolved the problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.