urbania / apple-news
dev-master
2019-03-25 22:45 UTC
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.3
- illuminate/contracts: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*|5.8.*
- imangazaliev/didom: ^1.14
- symfony/css-selector: ^2.7|^3.0|^4.2
- symfony/filesystem: ^3.0|^4.2
- webmozart/assert: ^1.4
Requires (Dev)
- doctrine/dbal: ^2.0
- fzaninotto/faker: ~1.4
- mockery/mockery: 0.9.*|1.0.*
- nette/php-generator: ^2.6|^3.2
- orchestra/testbench: 3.1.*|3.2.*|3.3.*|3.4.*|3.5.*|3.6.*|3.7.*|3.8.*
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ~7.0|^7.5|^8.0
- squizlabs/php_codesniffer: *
- symfony/finder: ^2.7|^3.0|^4.2
- vlucas/phpdotenv: ~1.0|^2.2
This package is auto-updated.
Last update: 2024-11-09 13:59:04 UTC
README
This package offer a wrapper around the Apple News API and Apple News Format in PHP. It includes support for Laravel, Wordpress and an HTML parser.
Installation
composer require urbania/apple-news
Laravel
Versions prior to 5.5
- Add the Service Provider in the config file
config/app.php
:
'providers' => [ // ... \Urbania\AppleNews\Laravel\AppleNewsServiceProvider::class, // ... ]
- Add the Facade in the config file
config/app.php
:
'facades' => [ // ... 'AppleNews' => \Urbania\AppleNews\Laravel\AppleNewsFacade::class, // ... ]
All versions
Publish the config file to config/apple-news.php
:
php artisan vendor:publish
Usage
Pure PHP
Create a test article:
require __DIR__ . '/vendor/autoload.php'; use Urbania\AppleNews\Article; $article = new Article([ 'identifier' => 'test-article', 'language' => 'en-US', 'version' => '1.7', 'layout' => [ 'columns' => 12, 'width' => 1024 ], 'title' => 'An article', 'components' => [ [ 'role' => 'title', 'text' => 'This is a title' ], [ 'role' => 'body', 'text' => 'This is a body' ] ] ]); echo $article->toJson();
Laravel
Create a test article: (when creating an article with the facade or the helper, it takes into account the default article
values found in config/apple-news.php
)
// Using the facade use AppleNews; $article = AppleNews::article([ 'identifier' => 'test-article', 'title' => 'An article', 'components' => [ [ 'role' => 'title', 'text' => 'This is a title' ], [ 'role' => 'body', 'text' => 'This is a body' ] ] ]); // Using the helper $article = article([ // ... same as above ]); echo $article->toJson();