php-tmdb / api

PHP 7.3+ API Wrapper for The Movie Database
MIT License
404 stars 112 forks source link

Can some php5.5 features be disabled? #83

Closed wagnered closed 9 years ago

wagnered commented 9 years ago

I guess, when I did that PR to add content ratings, I did it against the master branch as the Ampache code doesn't have the 2.0 code changes in it.

Anyway, I tried to update Ampache's Tmdb module to the latest and found out that the code cals /guzzlehttp/guzzle/tests/perf.php which requires PHP5.5: The owner of Ampache is not ready to move to PHP5.5.

I*s there a way to disable the Guzzle performance testing via Tmdb, or is it built into the GuzzleHttp API? Otherwise, I cannot update the Tmdb api in Ampache yet.

Thanks Ernie D

wtfzdotnet commented 9 years ago

@wagnered Guzzle is an dependency for the requests, you could implement your own http adapter though, otherwise I'd suggest maintaining your own fork based on 1.0 and repeat your changes there. What version of php is ampache compatible with though for starters?

wtfzdotnet commented 9 years ago

@wagnered also by looking at https://github.com/guzzle/guzzle/blob/5.2.0/composer.json it requires php 5.4 as a minimum, what exactly are you running into?

wagnered commented 9 years ago

Ampache is compatible with 5.4.*

In "/guzzlehttp/guzzle/tests/perf.php" the header states that php 5.5 or greater is required. The error that Eclipse is giving is in line 40:

    yield $client->createRequest('GET', '/guzzle-server/perf');

The error is: "Syntax error, unexpected $client", which is defined earlier on the script.

I assumed that the word 'yield' is a php function as it is not prefixed by "$", but a lookup of the word on php.net gives no results, so I'm not sure what is going on with that.

I'm not exactly sure that that is my problem, though. It might be an Ampache bug. I'm stepping through and it seems to be a bug in the autoloader code. But with Eclipse/xdebug, it's sometimes difficult to see what is actually happening.

It still might be a Guzzle or other module I'm missing. The main Guzzle download doesn't include all the other required Guzzle modules and only by stepping through the code and looking at the "use" statements did I find out what additional modules I needed to add.

Ernie

wagnered commented 9 years ago

OK, I think I see what's going on.

Your code is referring to, for example, "GuzzleHttp\Client" but the directory chain for the Guzzle framework is "guzzlehttp/guzzle/src/Client". Ampache's autoloader just splits up the class chain then adds each part to the base url until it finds an actual file.

I can see how to work around the problem, of getting the GuzzleHttp classes loaded: That's by moving the actual classes up one level to the Guzzle directory.

Alright, thanks for the input. I'll also see what I can do to have a better autoloader implemented into Ampache.

wagnered commented 9 years ago

One final note: WOW!!

It took me 7 hours stepping through the code to figure out all the additonal API/Frameworks required to get version 2.0.3 of the PHP-Tmdb-api module working.

All the GuzzleHttp APIs did not come in one package. And the directly structures of the various packages did not conform to the class "use" statements, so I had to re-arrange some packages to conform to the class "use" statement. The package GuzzleHttp/Streams was the only package I could find, but the "use" statements wanted "GuzzleHttp/Stream/*", so I had to rename the GuzzleHttp/Streams directory to conform to the script. There were a few others I had to rename and relocate to get the Tmdb module to work correctly.

If Ampache was set up as a C-M-V framework, the configuration might have been much easier.

Regards...

It does seem to be maybe a little faster than the earlier version, But I'll have a better idea when I scan a folder of 100+ videos.