jsonrai277/laravel-json-placeholder

A json placeholder integration for laravel

1.0.1 2024-08-06 11:19 UTC

This package is auto-updated.

Last update: 2024-11-06 11:47:11 UTC


README

A package that integrates Typicode Json placeholder with laravel. It creates a landing, listing and view pages for all the available resources posts, comments, albums, photos, todos, users.

Installation

Require the package.

composer require jsonrai277/laravel-json-placeholder

Publish necessary configs and views for customization. It copies the config to config/laravel-json-placeholder in laravel app and also the views to resources/views/vendor/laravel-json-placeholder directory.

php artisan vendor:publish --provider=JsonRai277\\LaravelJsonPlaceholder\\LaravelJsonPlaceholderServiceProvider

Once tag published visit the route /resources. It should render a nice landing page for all the available resources. Also, the config should be pretty self explanatory to override any settings.

Config

Retrieving config.

$config = config('laravel-json-placeholder.pagination_size'); // Returns 10 or whatever set on the config.
// Or
$config = JsonRai277\LaravelJsonPlaceholder\LaravelJsonPlaceholderConfig::getConfig('pagination_size');

Setting config at rung time.

JsonRai277\LaravelJsonPlaceholder\LaravelJsonPlaceholderConfig::setConfig('pagination_size', 10); // Sets 10.

Testing

You can run tests with:

vendor/bin/phpunit