LaravelPackages.net
Acme Inc.
Toggle sidebar
newtqnia/php

Official PHP SDK for the NewTqnia APIs. Retrieve bilingual technology news and integrate NewTqnia into PHP and Laravel applications.

0
0
v1.0.0
About newtqnia/php

newtqnia/php is a Laravel package for official php sdk for the newtqnia apis. retrieve bilingual technology news and integrate newtqnia into php and laravel applications.. It currently has 0 GitHub stars and 0 downloads on Packagist (latest version v1.0.0). Install it with composer require newtqnia/php. Discover more Laravel packages by newtqnia or browse all Laravel packages to compare alternatives.

Last updated

NewTqnia PHP SDK

Tests PHP License

The official PHP SDK for the NewTqnia technology news API, providing structured access to bilingual technology news for PHP and Laravel applications.

NewTqnia SDK Laravel editorial demo

When API content is displayed, the API terms require a visible Powered by NewTqnia link and preservation of the returned article URLs.

Why use the SDK?

  • Typed, immutable response objects instead of raw arrays
  • English and Arabic news, category filtering, and today/latest collections
  • PSR-18 and PSR-17 interoperability with automatic client discovery
  • Optional PSR-16 caching with ETag, If-None-Match, 304, and Cache-Control
  • Optional Laravel auto-discovery, facade, configuration, and Blade component

Requirements and installation

PHP 8.2 or later and a PSR-18 implementation:

composer require newtqnia/php guzzlehttp/guzzle

Plain PHP quick start

<?php
require __DIR__.'/vendor/autoload.php';

use NewTqnia\Client;

$client = new Client();
$response = $client->news()->today(locale: 'en', limit: 5);

foreach ($response->articles as $article) {
    echo $article->title.PHP_EOL;
    echo $article->url.PHP_EOL;
}

Explicit PSR injection is also supported:

$client = new Client(httpClient: $psr18Client, requestFactory: $psr17Factory);

Laravel quick start

Laravel discovers the package automatically. Optionally publish its configuration:

php artisan vendor:publish --tag=newtqnia-config
NEWTQNIA_BASE_URL=https://newtqnia.com
NEWTQNIA_API_KEY=
NEWTQNIA_CACHE_ENABLED=true
NEWTQNIA_CACHE_TTL=300
use NewTqnia\Laravel\Facades\NewTqnia;

$digest = NewTqnia::news()->latest(locale: 'en', limit: 6);

Render the required attribution with <x-newtqnia-attribution />.

The integration was verified in a temporary Laravel 12 application installed through a Composer path repository. It rendered live API data in desktop, mobile, dashboard, and Arabic RTL layouts:

| Mobile | Arabic RTL | Developer dashboard | | --- | --- | --- | | Mobile Laravel demo | Arabic RTL Laravel demo | Laravel developer dashboard |

Retrieving news

$today = $client->news()->today(locale: 'en', limit: 5);
$latest = $client->news()->latest(locale: 'ar', limit: 5);
$ai = $client->news()->latest(locale: 'en', limit: 10, category: 'ai');

$fluent = $client->news()->latest()
    ->locale('ar')
    ->limit(5)
    ->category('security')
    ->get();

Valid locales are en and ar; limits are 1–10. Category values are API category slugs.

Response objects

Digest exposes the documented API version, collection, optional date, timezone, locale, direction, publisher, attribution, generation time, articles, and links. Each Article exposes its ID, title, summary, category, image URL, preserved article URL, publication time, and read time. Use $digest->raw() when the original decoded response is needed.

Caching and errors

Pass any Psr\SimpleCache\CacheInterface implementation as cache:. Successful responses are cached, server max-age is honored, stale entries are revalidated with their ETag, and errors are never cached. The public API is limited to 60 requests per minute per IP.

Failures use the NewTqnia\Exception hierarchy: ValidationException, TransportException, InvalidResponseException, ApiException, RateLimitException, and ConfigurationException. See caching and error handling.

Attribution requirement

Applications displaying API content must visibly link “Powered by NewTqnia” to NewTqnia. The core helper is:

$attribution = \NewTqnia\NewTqnia::attribution();

The SDK never rewrites article URLs. Review the attribution guide and API terms.

Framework guides

Runtime dependencies

The small runtime dependency set has one job each:

  • psr/http-client and psr/http-factory define the interoperable HTTP transport contracts (their standard contracts bring PSR-7 messages transitively).
  • php-http/discovery finds an installed PSR-18 client and PSR-17 factory for zero-configuration construction; explicit injection remains supported.
  • psr/simple-cache powers the implemented, optional ETag response cache.

Laravel, Guzzle, PHPUnit, PHPStan, and PHP CS Fixer are development-only. The core has no framework, logging, serializer, date, or collection dependency.

Testing and development

composer check
NEWTQNIA_LIVE_TESTS=1 vendor/bin/phpunit tests/Integration/LiveApiTest.php
composer openapi:check

See CONTRIBUTING.md, SECURITY.md, and the MIT license.