Conversation
add badge update header
…, classes and files to look like our Ruby library
|
@Alaa-abdulridha I had a thought recently about how we go to the effort to create links back to the API, for example for pagination: What do you think about our clients having direct support for these? A function that tacks on the API key, validates the endpoint and handles the request for you. |
Thank you @Freaky , Good idea need more discussing, let's open an issue for it to address it later after deploying the library 👍 @jvmvik Sorry this took long 😞 |
Freaky
left a comment
There was a problem hiding this comment.
Thanks @Alaa-abdulridha, just one or two comments! My PHP's pretty rusty, I need to catch up on modern best-practices.
Might be nice to have some phpdoc API docs?
| @@ -0,0 +1,19 @@ | |||
| The MIT License (MIT) | |||
|
|
|||
There was a problem hiding this comment.
The MIT license is supposed to have a copyright notice here, or it's a bit difficult to comply with the bit that starts "The above copyright notice".
| Copyright 2024 SerpApi, LLC | |
| "engine" => "naver", | ||
| "query" => "paris", |
There was a problem hiding this comment.
Doesn't match the following text.
| "engine" => "naver", | |
| "query" => "paris", | |
| "engine" => "google", | |
| "q" => "coffee", |
| @@ -0,0 +1,167 @@ | |||
| <?php | |||
|
|
|||
There was a problem hiding this comment.
It was introduced after my PHP time, but I wonder if users generally expect libraries to be in their own namespaces these days?
| # Default target | ||
| all: install readme test |
| public function test_throws_when_api_key_invalid() { | ||
| $this->expectException(SerpApiException::class); | ||
| $this->expectExceptionMessageMatches('/Invalid API key/i'); | ||
| $client = new Client('not_valid_key'); | ||
| $client->search(['q' => 'Coffee']); | ||
| } |
| } finally { | ||
| if (PHP_VERSION_ID < 80500) { | ||
| curl_close($ch); | ||
| } | ||
|
|
||
| $ch = null; | ||
| } |
There was a problem hiding this comment.
curl_close() is deprecated as of PHP 8.5, so we intentionally avoid calling it on 8.5+.
The handle lifecycle is still bounded by try/finally, and we explicitly release the reference $ch = null to support long-running processes.
For legacy runtimes, we keep curl_close() behind PHP_VERSION_ID < 80500.”
| - name: Run test suite | ||
| run: composer run-script test | ||
| env: | ||
| API_KEY: ${{ secrets.API_KEY }} |
|
@galetahub Is this ready for review? |
|
@aciddjus, yes, it's ready for review. |
|
Since we are building the client using classes, should we use camelCase? e.g. |
|
We can also consider matching https://www.php-fig.org/psr/psr-12/ |
|
@strzibny, thanks for looking into it! The latest updates:
|
|
Things generally work for me, I haven't faced a major issue in writing and testing different scripts. Some other things we could consider. 1, Adding PHPStan (we would need to stay on 1.x because of our PHP 7.2support) 2, Extend 3, Extend 4, Personally I love being able to test libraries offline and I also dislike project README badges (they are native GitHub features for most, they add the issue of not being always loaded, they scream RED and therefore are offputting to users), but I understand this is the case for our other libraries to and it's just a matter of taste. |
|
@strzibny, can you approve the PR or request changes so that @galetahub knows what the next steps should be? I would rather release this sooner than later if stable, because we have known issues with the current library that are preventing users from using it efficiently. |
|
Thanks for your comment, @strzibny!
Currently, this library has a small
Agree with you. I removed
Done.
According to the badges we use in other integration libraries, I think it makes sense to keep them here as well. For me, badges add a bit more trust to the library 😃. |
|
After discussing it with @strzibny, we concluded that we should remove the CI badge and package downloads counter. The CI badge duplicates a native GitHub feature, sometimes badge won't load or shows a failed build. |
|
Thank you, @galetahub 👍 Can you please open a follow-up PR to replace the old version with the new on the website? Similar to: https://github.com/serpapi/SerpApi/pull/9618 BTW, there is a package badge seam to be broken.
|
|
@aciddjus, thanks for pointing it out. The package hasn’t been published yet, so the package badge is broken. I'm going to do it via GitHub actions. |
|
Got it. Thank you, sounds good! |

WIP