0

I added a new vendor to my file but when I wrote the App:import it is gives the error Error: Class 'App\Controller\App' not found.

Code:

App::import('Vendor', 'php-excel-reader/excel_reader2'); 

the file is in vendor\php-excel-reader\excel_reader2 It used to work for my php 2.x codes. So I wonder if things changed for cake 3.x. Any ideas?

Rey Norbert Besmonte
  • 791
  • 2
  • 12
  • 29
  • Possible duplicate of: https://stackoverflow.com/questions/26562930/how-to-import-vendor-files-in-cakephp-3x – JazzCat May 31 '17 at 07:29
  • already tried that. still getting "Error: Class 'App\Controller\excel_reader2' " when I add the $my_obj = new excel_reader2(); – Rey Norbert Besmonte May 31 '17 at 07:45
  • 1
    It doesn't seem to be loaded through composer, use this require_once(ROOT . 'vendor' . DS . 'php-excel-reader' . DS . 'excel_reader2' . DS . 'your_class_file.php'); – JazzCat May 31 '17 at 07:47
  • @JazzCat yup that the one I tried, after I added that there will be no error, then when I add "$my_obj = new excel_reader2(); " its gives back that error – Rey Norbert Besmonte May 31 '17 at 07:55
  • is the class name excel_reader2, is the filename excel_reader2.php ? Seems weird to name a class excel_reader2, try new excel_reader(); – JazzCat May 31 '17 at 07:56
  • the file is in : vendor\php-excel-reader\excel_reader2.php, its a php functionality that works on native php. But when I apply it on cake it does not work due to directory issue – Rey Norbert Besmonte May 31 '17 at 08:01
  • 1
    You only answered half of jazz cats questions, the question was whether there really is such a class, and looking at **https://code.google.com/archive/p/php-excel-reader/**, which I can only guess is what you're trying to use (?), there is no such class. – ndm May 31 '17 at 08:26
  • Possible duplicate of [How to import vendor files in CakePHP 3x](https://stackoverflow.com/questions/26562930/how-to-import-vendor-files-in-cakephp-3x) – drmonkeyninja May 31 '17 at 09:13

1 Answers1

0

Finding Paths to Namespaces

static Cake\Core\App::path(string $package, string $plugin = null)

Used to get locations for paths based on conventions:

// Get the path to Controller/ in your application

App::path('Controller');
Aman Kumar
  • 4,533
  • 3
  • 18
  • 40