K
K
Konstantin Prudnikov2017-11-10 23:39:21
Yii
Konstantin Prudnikov, 2017-11-10 23:39:21

Yii2 class not found?

In general, the question is: what is the easiest way you know to pull out the entire table from the excel file and place it in an array in a Yii2 project.
I used to do a project on OOP MVC without frameworks - it was necessary to pull out data from excel and use it for analysis. There were no problems - I connected one of the ready-made solutions ( https://github.com/PHPOffice/PHPExcel) and everything is OK, without crap and dancing.
And so I sat down on Yii2. 3rd day trying to connect - to no avail. I pumped up a bunch of classes, compiled a bunch of projects - sometimes namespacs get out, sometimes the class does not find it. If anyone knows the correct solution - please share.
For now a question such - why does not find in model Excel?
5a060fca2729b687086584.png5a060fd0d53cf282924129.png5a060fd79318e906725370.png5a060fdcaca6f661550496.png5a060fe272915583986239.png
Thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2017-11-11
@slo_nik

Goodnight.
If you have an Excel model in models, then why do you write in namespace moonland/phpexcel?
Write app\models
I used a similar extension, but it was a PHPOffice / PhpExcel extension
Installed via composer and accessed the extension classes like this:

$objInputType = \PHPExcel_IOFactory::identify($fileInput);
        $objReader = \PHPExcel_IOFactory::createReader($objInputType);

In namespace and in use did not specify the path to the extension at all.

A
Andrey Sanych, 2017-11-10
@mountpoint

namespace for the model you need to write like app\models, and not like you came up with it

M
Maxim Fedorov, 2017-11-13
@qonand

And so I sat down on Yii2. 3rd day trying to connect - to no avail. I pumped up a bunch of classes, compiled a bunch of projects - sometimes namespacs get out, sometimes the class does not find it. If anyone knows the right solution, please share.

So maybe it's worth flipping through the documentation before sitting down? which clearly states
Yii relies on the class autoloading mechanism to locate and include all required class files. It provides a high-performance class autoloader that is compliant with the PSR-4 standard
get acquainted with the class autoloading standard and understand how namespaces work ?
Your mistakes are related to ignorance of this, some solutions have already been proposed by slo_nik and Andrey Sanych . However, you should still read up on and understand namespaces if you don't want to run into similar problems every step of the way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question