TobiasFranek / webuntis

A API library that makes it easy to access the Webuntis JSON RPC 2.0 API
MIT License
28 stars 9 forks source link

Model Classes, Rooms, etc. not found #17

Closed InTerestedOWL closed 6 years ago

InTerestedOWL commented 6 years ago

Hello Mr. Franek, I am using your API for a project in school, but I am getting the error, that every standard-Model (Classes, Teachers, Rooms, Substitutions and so on) can't be found. I am a little bit in struggle, because it have to be finished next week on monday. Here is the Code I have so far:

try { $config = new WebuntisConfiguration([ 'admin' => [ 'server' => '', 'school' => '', 'username' => '', 'password' => '' ], 'only_admin' => true, 'disableCache' => true ]); var_dump($config); //Contains an object of WebuntisConfiguration error_log("Config ist eingeladen!"); $query = new Query(); var_dump($query); //Contains an object of Query, but array models is 0, but array repository is 2 $aClasses = $query->get('Classes')->findAll(); return $aClasses; } catch (Exception $oException) { error_log($oException->getMessage()); }

I have it installed with the composer and the php-version is up to date.

Hope to hear as fast as possible from you. Thanks!

Hab gerade gemerkt, dass du Deutsch sprichst. Kannst somit gerne auf Deutsch antworten!

TobiasFranek commented 6 years ago

Hey,

I would rather answer in english because if someone has the same problem that can be solved too. So to see whats really going on there i have to see some more things like the exact error message. Did you check the folder in vendor if all necessary files are there?

InTerestedOWL commented 6 years ago

Hey there! It is the error message from the Query-class : "Model $classname not found!"

vendor is, what I could see not there. Where it is hide? I have the TFranek/WebUntis/<src\bin\docs>/Configuration Path for example? It is possible, that I have to load only one time one class?

TobiasFranek commented 6 years ago

did you install the package via composer? because if you did there should be an vendor folder in your project root directory.

InTerestedOWL commented 6 years ago

yes my projectmanager has installed it over composer. composer is installing into an directory named libs. So we don't have any root directory and i don't see any vendor directory. Is there any way to make this directory after the composer has installed the api?

InTerestedOWL commented 6 years ago

Okay the libs directory is the vendor directory, but I can't get any models. That' s the problem. The libs directory contains the tfranek/webuntis/<src\bin\docs>/ directories, but it isn't able to load any Model?

TobiasFranek commented 6 years ago

The problem is somehow the YAMLConfiguration Class cannot find the meta data of the Models (.webuntis.yml) which are located at src/Resources/config/. Maybe it is because the glob() function is not working probably on your system. What could also be is that you execute the script outside the root directory (the libs folder is in the hierarchy below the executed script) that could result in not finding the model because it only searches for models in the directory of the executed script and above.

TobiasFranek commented 6 years ago

and which os are you using? on linux there could be a problem with the access rights.

hendrikheil commented 6 years ago

Hi there,

I am the "project manager" / old developer of the software @programerTV is trying to work on. We just resolved the issue! You were absolutely right with your guess. If others may have similar issues here is how we were able to solve it: We had our composer config set up to install libraries into libs/ instead of vendor/. We just changed our composer.json back to the default directory and voila: The globbing was working fine once again. If "vendor" in YAMLConfiguration.php was changed to "libs" that would also resolve the issue, but well that wasn't really desirable for obvious reasons :smile:

By the way, our script was calling from /core/controllers/somecontroller.php. Composer had it's installation directory in /libs - is that what you meant with

What could also be is that you execute the script outside the root directory (the libs folder is in the hierarchy below the executed script) that could result in not finding the model because it only searches for models in the directory of the executed script and above.

?

Any way, we got it working now! Thanks a bunch for your help!

TobiasFranek commented 6 years ago

If I work on the next patch I will maybe include a option to add an additional path for the configuration.

TobiasFranek commented 6 years ago

but if you want you can also add this feature. Just try to code it out and make a commit and i will review it.

hendrikheil commented 6 years ago

Well, I didn't really dive into the code too deep. I just helped my team to debug what was causing the issue. Maybe I'll look into how the whole thing works once I've got a little more freetime on my hand. I can't promise anything but I'll keep it in mind; maybe someone in my team wants to look into that ;)