laravel-strapi icon indicating copy to clipboard operation
laravel-strapi copied to clipboard

[BREAKING] Code refactoring

Open frugan-dev opened this issue 1 year ago • 7 comments

DONE

  • dropped support for Laravel <= 8
  • dropped support for PHP <= 8.1 (Laravel ^9 || ^10 already supports PHP 8.2 https://endoflife.date/laravel)
  • updated all composer packages
  • added shared method getResponse()
  • fixed $response returned by Cache::remember() https://stackoverflow.com/a/74783008/3929620
  • used closure in $response->throw()
  • revised esceptions classes, now extend Illuminate\Http\Client\RequestException
  • used Http::withToken() instead of Http::withHeaders()
  • used Http::withQueryParameters() instead of http_build_query()
  • added Http::withOptions() and Http::baseUrl()
  • renamed parameter $type to $name, as it is more consistent with the field used by Strapi
  • renamed $queryData to $queryParams, as it is more consistent with Http::withQueryParameters()
  • removed almost all parameters (e.g. $sortKey, $sortOrder, $populate, etc.) in favor of $queryParams, which allows greater control over the API parameters used
  • now $queryParams also allows you to use pagination by offset values (pagination[start] and pagination[limit]), which previously conflicted with pagination by page values (pagination[page] and pagination[limit]) set directly within the method collection()
  • added optional $cacheTime parameter to override the global value defined in STRAPI_CACHE_TIME per-call
  • removed the collectionCount() method, as the /api/$name/count entrypoint does not seem to exist anymore in Strapi v4 (?), and also the pagination[withCount] parameter exists and it's active by default
  • removed the entriesByField() method as it is superfluous, because it is possible to make the same call with the collection() method (see examples in README)
  • moved option STRAPI_FULL_URLS globally in .env file
  • removed $pluck parameter as it is superfluous to the primary functionality of this package: everyone is free to alter the response as they wish
  • incremented config('strapi.pagination.limit') from 20 to 25 (default Strapi pagination[pageSize])
  • revised the entire README file

TODO

  • update references in Strapi documentation https://github.com/strapi/documentation/blob/main/docusaurus/docs/dev-docs/integrations/laravel.md
  • might it be a good idea to add a F.A.Q. or Known issues section on the README? this could be included in this section, useful for those who have a local development setup (e.g. mkcert):
# .env.local
HTTP_CLIENT_VERIFY_SSL=false
// config/http.php
return [
    'client' => [
        'verify_ssl' => (bool) env('HTTP_CLIENT_VERIFY_SSL', true),
    ],
];
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Http;

public function boot(): void
{
    Http::globalOptions([
	'verify' => config('http.client.verify_ssl'),
    ]);
}

frugan-dev avatar Feb 24 '24 17:02 frugan-dev

Hi @dbfx, is there any problem accepting this pull request?

frugan-dev avatar May 20 '24 16:05 frugan-dev