You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For activity, content, quality, and OSV security, add the relevant provider factories (GitHub, jsDelivr, OSV) and pass them to the corresponding inspectors.
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
217
-
218
-
$cache = new FilesystemAdapter('packapi', 3600); // 1 hour TTL
219
-
220
-
$packApi = (new PackApiBuilder())
221
-
->useCache($cache)
222
-
->build();
223
-
```
205
+
Enable HTTP caching at the Symfony HTTP client level (e.g., `CachingHttpClient` with an HttpKernel `Store`). PackApi does not require a separate configuration object.
224
206
225
207
### Logging
226
208
227
-
Enable request logging for debugging:
228
-
229
-
```php
230
-
use Psr\Log\LoggerInterface;
231
-
232
-
$packApi = (new PackApiBuilder())
233
-
->withLogger($logger)
234
-
->build();
235
-
```
209
+
Pass a PSR‑3 logger to `HttpClientFactory` to log outgoing requests in examples and providers.
236
210
237
211
### GitHub Authentication
238
212
239
-
For higher rate limits, provide a GitHub token:
213
+
For higher GitHub rate limits, provide a token:
240
214
241
215
```php
242
216
// Via environment variable
243
217
$_ENV['GITHUB_TOKEN'] = 'ghp_your_token_here';
244
218
245
-
// Or directly
246
-
$packApi = (new PackApiBuilder())
247
-
->withGitHubToken('ghp_your_token_here')
248
-
->build();
219
+
// Pass the token to GitHubProviderFactory when creating providers
220
+
// $github = new GitHubProviderFactory($httpFactory, $_ENV['GITHUB_TOKEN'] ?? null);
249
221
```
250
222
251
223
## Architecture
252
224
253
-
PackAPI uses a clean, extensible architecture:
225
+
PackApi uses a clean, extensible architecture:
254
226
255
227
### Core Components
256
228
@@ -262,21 +234,21 @@ PackAPI uses a clean, extensible architecture:
262
234
263
235
### Provider Pattern
264
236
237
+
Each inspector accepts one or more providers from the corresponding factory. Providers are tried in order until one succeeds.
238
+
265
239
```php
266
-
// Each inspector can have multiple providers
267
-
$securityInspector = new SecurityInspector([
268
-
new OSVSecurityProvider($httpClient), // OSV Database
269
-
new GitHubSecurityProvider($httpClient), // GitHub Advisories
270
-
new PackagistSecurityProvider($httpClient) // Packagist Security
240
+
$security = new SecurityInspector([
241
+
$osvFactory->createSecurityProvider(),
242
+
$githubFactory->createSecurityProvider(),
243
+
$packagistFactory->createSecurityProvider(),
271
244
]);
272
245
273
-
// Providers are tried in order until one succeeds
0 commit comments