### Creating New Laravel Project with Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/index.md This command downloads and executes a Laravel setup script using `curl` to create a new Laravel project directory named `jsonapi-tutorial`. It requires `curl` and `bash` to be available. The script handles the necessary composer and dependency installations. ```bash curl -s https://laravel.build/jsonapi-tutorial | bash ``` -------------------------------- ### Installing Laravel API Starter Kit - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/index.md Instructs the user to run the 'herd php artisan install:api' command. This command installs Laravel Sanctum, which is used for API authentication in the tutorial, and sets up the basic API routing files within the Laravel application. ```bash herd php artisan install:api ``` -------------------------------- ### Installing Laravel JSON:API Testing Package (Composer) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/testing/index.md This command installs the `laravel-json-api/testing` package as a development dependency using Composer. It is required to use the testing helpers provided by the package. ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Installing Laravel JSON:API Testing Package (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/testing/index.md Command to install the Laravel JSON:API testing package using Composer. This command installs the package as a development dependency. It is required to use the testing features described in the document. ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Installing Laravel JSON:API Testing Package (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/index.md Installs the `laravel-json-api/testing` package as a development dependency using Composer. This package provides test helpers for making JSON:API requests and asserting responses. ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Installing Laravel JSON:API Testing Package (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/testing/index.md Installs the `laravel-json-api/testing` Composer package as a development dependency. This package provides test helpers for building JSON:API requests and asserting responses in Laravel tests. ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Creating Laravel Project via Curl | bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/index.md This command downloads the Laravel installer script via curl and pipes it to bash for execution, creating a new Laravel project directory named `jsonapi-tutorial`. It sets up the basic project structure, including Docker/Sail configuration. Requires Composer and Docker. ```bash curl -s https://laravel.build/jsonapi-tutorial | bash ``` -------------------------------- ### Creating Laravel Project using laravel.build (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/tutorial/index.md This command downloads and executes the `laravel.build` script using `curl` and `bash` to quickly set up a new Laravel project named `jsonapi-tutorial` specifically for the JSON:API tutorial. It requires `curl` and `bash` to be installed on the host system. The output is a new Laravel project directory containing the initial application files. ```bash curl -s https://laravel.build/jsonapi-tutorial | bash ``` -------------------------------- ### Initializing New Laravel Project using Herd - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/index.md Provides the necessary bash commands to navigate to the Herd directory, create a new Laravel project named 'jsonapi-tutorial', change into the newly created project directory, and open the project in a web browser using Herd. This assumes Laravel Herd is installed and configured. ```bash cd ~/Herd laravel new jsonapi-tutorial cd jsonapi-tutorial herd open ``` -------------------------------- ### Installing Laravel JSON:API Testing Package (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/testing/index.md Installs the `laravel-json-api/testing` Composer package as a development dependency. This package provides test helpers and assertions specifically designed for testing Laravel applications that adhere to the JSON:API specification. Requires Composer to be installed and available in the system's PATH. ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Verifying Laravel Artisan Version - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/index.md Demonstrates how to use the 'herd php artisan -V' command to check the installed Laravel version via the Artisan command-line tool. This confirms that Artisan is correctly configured and accessible for running further commands needed for the tutorial. ```bash herd php artisan -V ``` -------------------------------- ### Starting Laravel Sail Development Environment with Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/index.md This command navigates into the newly created `jsonapi-tutorial` directory and then starts the Laravel Sail Docker containers using the provided `sail` script. This command is used to launch the application's development environment, making it accessible locally. ```bash cd jsonapi-tutorial && ./vendor/bin/sail up ``` -------------------------------- ### Starting Laravel Application with Sail (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/tutorial/index.md This command navigates into the newly created `jsonapi-tutorial` project directory and then uses the Sail wrapper script (`./vendor/bin/sail`) to build and start the necessary Docker containers for the Laravel application in the background. It requires Docker to be running and the Sail script to be executable. The expected output is Docker logs indicating the containers are starting. ```bash cd jsonapi-tutorial && ./vendor/bin/sail up ``` -------------------------------- ### Default Laravel API Routes - PHP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/tutorial/03-server-and-schemas.md The standard content of the `routes/api.php` file in a default Laravel installation, showing the basic setup including middleware and a sample user route. ```PHP use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | API Routes |-------------------------------------------------------------------------- | | Here is where you can register API routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | is assigned the "api" middleware group. Enjoy building your API! | */ Route::middleware('auth:sanctum')->get('/user', function (Request $request) { return $request->user(); }); ``` -------------------------------- ### Starting Laravel Sail Docker Environment | bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/index.md Changes the current directory to the newly created `jsonapi-tutorial` project and then uses the `sail` executable within the `vendor/bin` directory to start the Docker containers required for the Laravel application's development environment (web server, database, etc.). Requires the project directory and Docker to be running. ```bash cd jsonapi-tutorial && ./vendor/bin/sail up ``` -------------------------------- ### Installing Laravel JSON:API Packages with Composer (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/getting-started/index.md Use Composer to add the main `laravel-json-api/laravel` package and the development-only `laravel-json-api/testing` package to your Laravel project's dependencies. This is the standard way to install PHP packages and their dependencies. ```bash composer require laravel-json-api/laravel:^1.1 composer require --dev laravel-json-api/testing:^1.1 ``` -------------------------------- ### Installing Laravel JSON:API Packages with Composer (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/03-server-and-schemas.md Use Composer to install the main `laravel-json-api/laravel` package and the `laravel-json-api/testing` package for development purposes. These packages provide the core functionality and testing utilities for building JSON:API compliant APIs in Laravel. ```bash herd composer require laravel-json-api/laravel herd composer require --dev laravel-json-api/testing ``` -------------------------------- ### Checking Laravel Artisan Version with Sail and Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/index.md This command uses the Laravel Sail wrapper script (`vendor/bin/sail`) to execute the `artisan -V` command within the Docker container. It verifies that the Artisan command-line tool is accessible and reports the installed Laravel framework version. ```bash vendor/bin/sail artisan -V ``` -------------------------------- ### Install Laravel JSON:API Dependencies (Composer) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/03-server-and-schemas.md Installs the core Laravel JSON:API package and the testing utilities via Composer. These packages are required to build JSON:API compliant APIs in a Laravel application. ```bash herd composer require laravel-json-api/laravel herd composer require --dev laravel-json-api/testing ``` -------------------------------- ### Default Laravel API Routes (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/03-server-and-schemas.md Displays the default content of the `routes/api.php` file in a standard Laravel installation, typically containing a route for retrieving the authenticated user. This is the starting point before adding JSON:API specific routes. ```php use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; Route::get('/user', function (Request $request) { return $request->user(); })->middleware('auth:sanctum'); ``` -------------------------------- ### Publishing Laravel JSON:API Configuration (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/getting-started/index.md Run this Artisan command to publish the package's default configuration file (`config/jsonapi.php`) to your application. This allows you to customize various settings for the JSON:API implementation. ```bash php artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### Fetching Post Resource HTTP Request Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/03-server-and-schemas.md Demonstrates the initial HTTP GET request structure for fetching a single post resource by its type and ID according to the JSON:API specification. Requires the `Accept` header set to `application/vnd.api+json`. ```http GET http://jsonapi-tutorial.test/api/v1/posts/1 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Generating JSON:API Server | Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/servers/index.md This Artisan command generates a new server class file with the specified name. It is the first step in creating a new JSON:API server instance in your Laravel application. ```bash php artisan jsonapi:server v1 ``` -------------------------------- ### Installing Laravel API Starter Kit - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/index.md This bash command executes the `install:api` Artisan command using Herd's PHP wrapper. It installs the necessary components for building an API, specifically the Laravel Sanctum package for authentication and creates the `routes/api.php` file. This prepares the application for API development as required by the JSON:API tutorial. ```bash herd php artisan install:api ``` -------------------------------- ### Opening Laravel Project in Browser via Herd - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/index.md Shows how to navigate into the created project directory and open it in the browser using the 'herd open' command. This step is performed after the initial project creation command finishes and is used to verify the default Laravel welcome page is displayed. ```bash cd jsonapi-tutorial herd open ``` -------------------------------- ### Adding MakesJsonApiRequests Trait to TestCase (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/testing/index.md Modifies the base test case class (`Tests\TestCase`) in a Laravel application to include the `MakesJsonApiRequests` trait from the testing package. Adding this trait is a necessary setup step that enables the `jsonApi()` method on the test case, allowing for fluent construction of JSON:API test requests. Requires the `laravel-json-api/testing` package to be installed. ```php namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; use LaravelJsonApi\Testing\MakesJsonApiRequests; abstract class TestCase extends BaseTestCase { use CreatesApplication; use MakesJsonApiRequests; } ``` -------------------------------- ### Using Generic JsonApiController (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/routing/controllers.md Example demonstrating how to register a resource route for 'posts' using the built-in `LaravelJsonApi\Laravel\Http\Controllers\JsonApiController`. This approach is suitable for resources that do not require any custom controller logic or action hooks, simplifying routing setup. ```php use LaravelJsonApi\Laravel\Http\Controllers\JsonApiController; JsonApiRoute::server('v1') ->prefix('v1') ->resources(function ($server) { $server->resource('posts', JsonApiController::class); }); ``` -------------------------------- ### Making JSON:API GET Request and Asserting Response (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/testing/index.md This example shows how to use the `jsonApi()` method to build a test GET request for a JSON:API endpoint, including specifying expected resource type and included paths. It then demonstrates using the `assertFetchedOneExact` method to validate the response against an expected resource object. ```php public function test(): void { $expected = // ... our expected posts resource object. $response = $this ->jsonApi() ->expects('posts') ->includePaths('author', 'tags') ->get('/api/v1/posts'); $response->assertFetchedOneExact($expected); } ``` -------------------------------- ### Creating New Laravel Project with Herd - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/index.md This bash snippet navigates to the Herd projects directory, creates a new Laravel application named `jsonapi-tutorial` using the `laravel new` command (prompting for configuration options), changes into the new project directory, and opens the project URL in the browser via Herd. It's used for initializing the project for the tutorial, requiring Herd to be installed and running. ```bash cd ~/Herd laravel new jsonapi-tutorial cd jsonapi-tutorial herd open ``` -------------------------------- ### Calculating Base URI Method | PHP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/servers/index.md This method provides a way to calculate the base URI programmatically instead of using a fixed property. The example shows how to cache the result for performance if the calculation is expensive. ```php /** * @return string */ protected function baseUri(): string { if ($this->baseUri) { return $this->baseUri; } return $this->baseUri = '...calculated value'; } ``` -------------------------------- ### Example HTTP GET Request with Filters HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/digging-deeper/non-eloquent.md Provides an example of an HTTP GET request to the index endpoint (`/api/v1/sites`) demonstrating how to use the `filter` query parameter. This specific example shows how to request sites with slugs 'foo' or 'bar', along with the required JSON:API Accept header. ```http GET /api/v1/sites?filter[slugs][]=foo&filter[slugs][]=bar HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Install Laravel JSON:API Packages via Composer Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/03-server-and-schemas.md Installs the core laravel-json-api package and the testing package using Composer, typically within a Sail environment. These commands add the necessary dependencies to the project. ```bash vendor/bin/sail composer require laravel-json-api/laravel vendor/bin/sail composer require --dev laravel-json-api/testing ``` -------------------------------- ### Requesting Paginated Non-Eloquent Resources - HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/digging-deeper/non-eloquent.md Provides an example HTTP GET request to retrieve paginated resources (`sites`) using the standard `page[number]` and `page[size]` query parameters supported by the Enumerable Pagination setup. Requires the resource endpoint to be configured with pagination. ```http GET /api/v1/sites?page[number]=1&page[size]=25 Accept: application/vnd.api+json ``` -------------------------------- ### Example Paged GET Request HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/digging-deeper/non-eloquent.md An example HTTP GET request showing how a client would request the 'sites' resource with pagination parameters, specifically asking for page 1 with 25 items per page according to the JSON:API specification. ```http GET /api/v1/sites?page[number]=1&page[size]=25 Accept: application/vnd.api+json ``` -------------------------------- ### Example GET Request for Polymorphic Relationship (HTTP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/digging-deeper/polymorphic-to-many.md This HTTP snippet shows an example GET request to fetch the resources belonging to a polymorphic 'media' relationship on a specific 'post' resource (ID 1). The request targets the relationship route defined on the server. ```http GET /api/v1/posts/1/media HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Running Database Migrations Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/02-models.md Execute the `migrate` Artisan command to run all pending migrations, creating or updating database tables according to the defined migration files. ```bash herd php artisan migrate ``` -------------------------------- ### Example HTTP GET Request with Filter Parameter Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/digging-deeper/non-eloquent.md Illustrates how an API client can include query parameters, specifically a `filter` for the 'name' property, when requesting a specific 'site' resource using a GET request. This example shows filtering by checking if the name contains 'Test'. ```HTTP GET /api/v1/sites/?filter[name]=Test HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Install Laravel JSON:API Composer Packages (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/03-server-and-schemas.md Installs the core Laravel JSON:API package and the testing utilities via Composer. These packages are required to add JSON:API capabilities to the Laravel application. ```bash composer require laravel-json-api/laravel:^1.1 composer require --dev laravel-json-api/testing:^1.1 ``` -------------------------------- ### Checking Laravel Version with Sail Artisan (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/tutorial/index.md This command executes the `artisan` command with the `-V` flag inside the Docker container managed by Laravel Sail, allowing verification that Artisan commands are accessible within the Sail environment. It requires Laravel Sail to be running. The expected output is the version number of the installed Laravel framework. ```bash vendor/bin/sail artisan -V ``` -------------------------------- ### Implement PostSeeder Run Method for Laravel PHP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/02-models.md This PHP code implements the `run` method of the `PostSeeder` class. It creates sample data including two users, two tags, a blog post, and a comment. It demonstrates using Laravel Eloquent models to persist data, establish relationships, and utilize helper functions like `bcrypt`, `now`, `associate`, and `saveMany` during the seeding process. ```php namespace Database\Seeders; use App\Models\Comment; use App\Models\Post; use App\Models\Tag; use App\Models\User; use Illuminate\Database\Seeder; class PostSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $author = User::create([ 'name' => 'Artie Shaw', 'email' => 'artie.shaw@jsonapi-tutorial.test', 'password' => bcrypt('password'), 'email_verified_at' => now(), ]); $commenter = User::create([ 'name' => 'Benny Goodman', 'email' => 'benny.goodman@jsonapi-tutorial.test', 'password' => bcrypt('password'), 'email_verified_at' => now(), ]); $tag1 = Tag::create(['name' => 'Laravel']); $tag2 = Tag::create(['name' => 'JSON:API']); $post = new Post([ 'title' => 'Welcome to Laravel JSON:API', 'published_at' => now(), 'content' => 'In our first blog post, you will learn all about Laravel JSON:API...', 'slug' => 'welcome-to-laravel-jsonapi', ]); $post->author()->associate($author)->save(); $post->tags()->saveMany([$tag1, $tag2]); $comment = new Comment([ 'content' => 'Wow! Great first blog article. Looking forward to more!', ]); $comment->post()->associate($post); $comment->user()->associate($commenter)->save(); } } ``` -------------------------------- ### Publishing Configuration Artisan Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/getting-started/index.md Publishes the `laravel-json-api` configuration file to `config/jsonapi.php` using the Laravel Artisan console. This allows customization of package settings. Requires Laravel and Artisan. ```bash php artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### Initial JSON:API Server Class (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/03-server-and-schemas.md Shows the default structure and content of the generated `Server.php` file for a new JSON:API server, including its namespace, base URI, and placeholder methods for serving and schemas. ```php namespace App\JsonApi\V1; use LaravelJsonApi\Core\Server\Server as BaseServer; class Server extends BaseServer { /** * The base URI namespace for this server. * * @var string */ protected string $baseUri = '/api/v1'; /** * Bootstrap the server when it is handling an HTTP request. * * @return void */ public function serving(): void { // no-op } /** * Get the server's list of schemas. * * @return array */ protected function allSchemas(): array { return [ // @TODO ]; } } ``` -------------------------------- ### Making and Asserting JSON:API GET Request (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/testing/index.md Demonstrates how to use the `jsonApi()` method from the `MakesJsonApiRequests` trait to construct a GET request to a JSON:API endpoint, including specifying the expected resource type and includes. It then shows how to use the `assertFetchedOneExact()` assertion method to verify the response data. ```php public function test(): void { $expected = // ... our expected posts resource object. $response = $this ->jsonApi() ->expects('posts') ->includePaths('author', 'tags') ->get('/api/v1/posts'); $response->assertFetchedOneExact($expected); } ``` -------------------------------- ### Example To-Many Relationship Query (HTTP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/schemas/pagination.md Shows an example HTTP GET request to fetch a related resource collection (`posts` of a `user`) via a to-many relationship endpoint, illustrating where pagination validation rules would apply. ```http GET /api/v1/users/123/posts HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Running Database Migrations using Artisan Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/02-models.md This bash command executes all pending database migrations defined in the application's migration files. It creates or alters database tables according to the migration logic. ```bash vendor/bin/sail artisan migrate ``` -------------------------------- ### Verifying Laravel Artisan Version - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/index.md This bash command uses the `herd php` wrapper to execute the `artisan -V` command within the `jsonapi-tutorial` project directory. It checks that the Laravel Artisan command-line interface is accessible and outputs its version, confirming the environment is set up to run Artisan commands. ```bash herd php artisan -V ``` -------------------------------- ### Installing Laravel JSON:API Packages with Composer (bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/getting-started/index.md Installs the core `laravel-json-api/laravel` package and the `laravel-json-api/testing` package as a development dependency using Composer. This command downloads the necessary files and updates the project's `composer.json` and `composer.lock` files. ```bash composer require laravel-json-api/laravel ``` ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Implementing PostSeeder Logic (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/02-models.md Defines the `run` method for the `PostSeeder` class, which creates sample `User`, `Tag`, `Post`, and `Comment` records and establishes relationships between them for database seeding in a Laravel application. Requires `User`, `Post`, `Tag`, and `Comment` model classes. ```php namespace Database\Seeder;\n\nuse App\Models\Comment;\nuse App\Models\Post;\nuse App\Models\Tag;\nuse App\Models\User;\nuse Illuminate\Database\Seeder;\n\nclass PostSeeder extends Seeder\n{\n /**\n * Run the database seeds.\n */\n public function run(): void\n {\n $author = User::create([\n 'name' => 'Artie Shaw',\n 'email' => 'artie.shaw@jsonapi-tutorial.test',\n 'password' => bcrypt('password'),\n 'email_verified_at' => now(),\n ]);\n\n $commenter = User::create([\n 'name' => 'Benny Goodman',\n 'email' => 'benny.goodman@jsonapi-tutorial.test',\n 'password' => bcrypt('password'),\n 'email_verified_at' => now(),\n ]);\n\n $tag1 = Tag::create(['name' => 'Laravel']);\n $tag2 = Tag::create(['name' => 'JSON:API']);\n\n $post = new Post([\n 'title' => 'Welcome to Laravel JSON:API',\n 'published_at' => now(),\n 'content' => 'In our first blog post, you will learn all about Laravel JSON:API...',\n 'slug' => 'welcome-to-laravel-jsonapi',\n ]);\n\n $post->author()->associate($author)->save();\n $post->tags()->saveMany([$tag1, $tag2]);\n\n $comment = new Comment([\n 'content' => 'Wow! Great first blog article. Looking forward to more!',\n ]);\n\n $comment->post()->associate($post);\n $comment->user()->associate($commenter)->save();\n }\n} ``` -------------------------------- ### Example HTTP Request to Relationship Endpoint Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/pagination.md An example HTTP GET request demonstrating how a client might query a to-many relationship (`users/123/posts`). This request would fail validation if pagination parameters are required by default, illustrating the need for conditional validation. ```http GET /api/v1/users/123/posts HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Making JSON:API GET Request and Asserting Response (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/testing/index.md Demonstrates how to use the `jsonApi()` method provided by the `MakesJsonApiRequests` trait to construct and execute a GET request targeting a JSON:API endpoint. It shows how to specify the expected resource type (`expects`), include related resources (`includePaths`), send the request (`get`), and assert the response content against an expected resource object using `assertFetchedOneExact`. Requires the `MakesJsonApiRequests` trait to be used on the test class. ```php public function test(): void { $expected = // ... our expected posts resource object. $response = $this ->jsonApi() ->expects('posts') ->includePaths('author', 'tags') ->get('/api/v1/posts'); $response->assertFetchedOneExact($expected); } ``` -------------------------------- ### Executing Database Seeders (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/02-models.md Command to execute the configured database seeders in a Laravel application using the `artisan` command-line tool, prefixed by `herd`, populating the database with the data defined in the seeder classes. ```bash herd php artisan db:seed ``` -------------------------------- ### HTTP GET Request Invalid Accept Header HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/requests/compliance.md Example of a GET request to a JSON:API endpoint where the client requests a non-JSON:API media type ('application/json') in the Accept header. This demonstrates how the server will reject requests that do not ask for the correct content type. ```http GET /api/v1/posts/1 HTTP/1.1 Accept: application/json ``` -------------------------------- ### Example GET Request for Relationship - HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/requests/query-parameters.md This HTTP snippet illustrates a GET request to fetch the identifiers of resources linked through a relationship (tags) for a specific resource (post with ID 123). This type of request is what the `isViewingRelationship` check would identify as a show-relationship action. ```http GET /api/v1/posts/123/relationships/tags HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Running Laravel Database Seeders - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/02-models.md This command uses the Laravel Artisan console to execute the database seeders configured in the `DatabaseSeeder` class. It triggers the `run` method of `DatabaseSeeder`, which in turn calls any other registered seeders (like `PostSeeder` in this case), populating the database with the defined data. This is the final step to apply the seeding logic. ```bash herd php artisan db:seed ``` -------------------------------- ### Running Laravel Database Seeders (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/02-models.md Executes the configured database seeders to populate the database with the defined initial data. This command runs the `run` method of the main `DatabaseSeeder` class, which in turn calls the `PostSeeder`. ```bash vendor/bin/sail artisan db:seed ``` -------------------------------- ### Creating Models and Migrations using Artisan Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/02-models.md These bash commands use the Laravel Artisan CLI via Sail to generate new Eloquent model classes and their associated database migration files for the Post, Tag, and Comment entities. ```bash vendor/bin/sail artisan make:model Post --migration vendor/bin/sail artisan make:model Tag --migration vendor/bin/sail artisan make:model Comment --migration ``` -------------------------------- ### GET Request with Non-JSON:API Accept Header (HTTP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/requests/compliance.md Example of a GET request to retrieve a post where the client specifies `application/json` in the `Accept` header instead of the required `application/vnd.api+json`. This demonstrates the scenario that triggers a `406 Not Acceptable` response due to a content negotiation failure on the Accept header. ```http GET /api/v1/posts/1 HTTP/1.1 Accept: application/json ``` -------------------------------- ### Updating Laravel Post Seeder Logic - PHP Diff Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/02-models.md This diff shows the changes needed in the `PostSeeder`'s `run` method to create sample database records. It demonstrates how to create users, tags, posts, and comments using Eloquent models and their relationships, including associating authors and tags with posts and linking comments to posts and users. This code populates the database with necessary initial data for a blog application tutorial. ```diff namespace Database\Seeders; +use App\Models\Comment; +use App\Models\Post; +use App\Models\Tag; +use App\Models\User; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class PostSeeder extends Seeder { /** * Run the database seeds. */ public function run(): void { - // + $author = User::create([ + 'name' => 'Artie Shaw', + 'email' => 'artie.shaw@jsonapi-tutorial.test', + 'password' => bcrypt('password'), + 'email_verified_at' => now(), + ]); + + $commenter = User::create([ + 'name' => 'Benny Goodman', + 'email' => 'benny.goodman@jsonapi-tutorial.test', + 'password' => bcrypt('password'), + 'email_verified_at' => now(), + ]); + + $tag1 = Tag::create(['name' => 'Laravel']); + $tag2 = Tag::create(['name' => 'JSON:API']); + + $post = new Post([ + 'title' => 'Welcome to Laravel JSON:API', + 'published_at' => now(), + 'content' => 'In our first blog post, you will learn all about Laravel JSON:API...',O + 'slug' => 'welcome-to-laravel-jsonapi', + ]); + + $post->author()->associate($author)->save(); + $post->tags()->saveMany([$tag1, $tag2]); + + $comment = new Comment([ + 'content' => 'Wow! Great first blog article. Looking forward to more!', + ]); + + $comment->post()->associate($post); + $comment->user()->associate($commenter)->save(); } } ``` -------------------------------- ### Example GET Request for Relationship Identifiers - HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/requests/query-parameters.md This HTTP snippet demonstrates a typical GET request used to retrieve the identifiers of resources in a relationship (e.g., tags for a post) as defined by the JSON:API specification. This type of request is what the `isViewingRelationship` helper method is designed to detect. ```http GET /api/v1/posts/123/relationships/tags HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Publishing Laravel JSON:API Configuration (bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/getting-started/index.md Executes the Laravel Artisan command `vendor:publish` to copy the default configuration file from the `LaravelJsonApi\Laravel\ServiceProvider` to the application's `config` directory. This allows customization of the package's settings. ```bash php artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### Example GET Request for JSON:API Relationship Data - HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/requests/query-parameters.md Demonstrates the structure of an HTTP GET request used to fetch resource identifier(s) for a specific relationship (`tags`) of a parent resource (`posts/123`) according to the JSON:API specification. This type of request corresponds to the 'show-relationship' action. ```HTTP GET /api/v1/posts/123/relationships/tags HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Filtering Posts by Author ID (HTTP GET) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/08-fetching-resources.md Provides an example of an HTTP GET request to retrieve posts filtered by author IDs 1 and 3 using the `filter[author]` query parameter. It also includes the `include=author` parameter to embed the author relationship in the response and pagination parameters. ```http GET http://jsonapi-tutorial.test/api/v1/posts?filter[author][]=1&filter[author][]=3&include=author&page[number]=1&page[size]=5 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Initial Post Table Migration PHP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/02-models.md This is the standard structure of a newly generated Laravel migration file for creating a table. It includes basic imports, the Schema facade, and `up()` and `down()` methods to manage table creation and dropping, pre-configured with 'id' and 'timestamps' columns. ```php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('posts', function (Blueprint $table) { $table->id(); $table->timestamps(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('posts'); } }; ``` -------------------------------- ### HTTP GET Request Without Any Page Parameters Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/schemas/pagination.md An example HTTP GET request for a Laravel JSON:API endpoint (`/api/v1/posts`) that contains no page-related query parameters. This type of request is used to illustrate a scenario where default server-side pagination settings configured on the schema would be applied to ensure a paginated response. ```http GET /api/v1/posts HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Example HTTP GET Request for Reading Resource by ID Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/digging-deeper/non-eloquent.md Shows the standard HTTP GET request format used to retrieve a specific 'site' resource based on its unique slug (ID) via the JSON:API endpoint `/api/v1/sites/`. It includes the required `Accept` header set to `application/vnd.api+json`. ```HTTP GET /api/v1/sites/ HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Creating Models using Artisan Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/02-models.md Use the Laravel Artisan command-line tool to generate new Eloquent models and their associated database migration files. The '--migration' flag ensures a migration file is created alongside the model. ```bash herd php artisan make:model Post --migration herd php artisan make:model Tag --migration herd php artisan make:model Comment --migration ``` -------------------------------- ### Publish Laravel JSON:API Configuration (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/03-server-and-schemas.md Publishes the default configuration file for the Laravel JSON:API package to the application's `config` directory. This allows for customization of server registration and other settings. ```bash vendor/bin/sail artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### Making a JSON:API Test Request and Asserting Response (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/index.md Demonstrates a basic test method using the `jsonApi()` builder to construct a GET request to `/api/v1/posts`, including specific include paths. It then asserts that the response contains exactly the expected resource object using `assertFetchedOneExact`. Requires the `MakesJsonApiRequests` trait. ```php public function test(): void { $expected = // ... our expected posts resource object. $response = $this ->jsonApi() ->expects('posts') ->includePaths('author', 'tags') ->get('/api/v1/posts'); $response->assertFetchedOneExact($expected); } ``` -------------------------------- ### Publish Laravel JSON:API Configuration (Artisan) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/tutorial/03-server-and-schemas.md Publishes the default configuration file for the Laravel JSON:API package to the application's `config` directory, allowing customization of settings. ```bash herd php artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### HTTP GET Request Without Page Size Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/schemas/pagination.md An example HTTP GET request to a Laravel JSON:API endpoint (`/api/v1/posts`) including a page number parameter (`page[number]=1`) but omitting the page size parameter. This scenario demonstrates when the server will use the default page size configured on the Eloquent model or resource schema. ```http GET /api/v1/posts?page[number]=1 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Creating a Laravel JSON:API Server (Bash) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/03-server-and-schemas.md Run this Artisan command to generate a new JSON:API server class named 'v1'. The command creates the `app/JsonApi/V1/Server.php` file, which will contain the configuration specific to this API server, such as its base URI and registered schemas. ```bash herd php artisan jsonapi:server v1 ``` -------------------------------- ### Client Request for WhereIn Filter (Delimiter) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client requests resources using the 'WhereIn' filter with a comma-separated string of values. ```http GET /api/v1/posts?filter[category]=foo,bar HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Requiring Main Package Composer Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/getting-started/index.md Adds the main `laravel-json-api/laravel` package as a project dependency using Composer. This command downloads the package and its required dependencies. Requires Composer and a Laravel project. ```bash composer require laravel-json-api/laravel:^2.6 ``` -------------------------------- ### Client Request for WhereIdNotIn Filter (Array) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client excludes multiple resources using the 'WhereIdNotIn' filter with an array of IDs. ```http GET /api/v1/posts?filter[exclude][]=3&filter[exclude][]=9 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Default Laravel API Routes PHP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/03-server-and-schemas.md Displays the initial content of the `routes/api.php` file in a default Laravel installation, typically containing only a placeholder route for user authentication. ```PHP use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | API Routes |-------------------------------------------------------------------------- | | Here is where you can register API routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | is assigned the "api" middleware group. Enjoy building your API! | */ Route::middleware('auth:sanctum')->get('/user', function (Request $request) { return $request->user(); }); ``` -------------------------------- ### Client Request for WhereIdIn Filter (Array) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client requests multiple resources using the 'WhereIdIn' filter with an array of IDs. ```http GET /api/v1/posts?filter[id][]=3&filter[id][]=9 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Run Laravel Database Seeders using Sail Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/02-models.md This bash command executes the database seeders registered in the main `DatabaseSeeder` class using the Laravel Artisan command-line interface via Sail. This command will trigger the `run` method of the `DatabaseSeeder` and any seeders it calls. It's the final step to populate the database with the sample data defined in the seeder files. ```bash vendor/bin/sail artisan db:seed ``` -------------------------------- ### Client Request for Renamed WhereHas Filter Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request using a custom filter name ('with-comments') for the 'WhereHas' filter, as defined in the schema. ```http GET /api/v1/posts?filter[with-comments][user]=123 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Installing Laravel JSON:API Packages via Composer Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/getting-started/index.md These Composer commands install the main laravel-json-api package as a required dependency and the testing helper package as a development-only dependency. This is the first step to integrate the library into a Laravel project. ```bash composer require laravel-json-api/laravel ``` ```bash composer require --dev laravel-json-api/testing ``` -------------------------------- ### Client Request for Renamed WhereDoesntHave Filter Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request using a custom filter name ('without-comments') for the 'WhereDoesntHave' filter, as defined in the schema. ```http GET /api/v1/posts?filter[without-comments][user]=123 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Making and Asserting JSON:API Test Request (PHP) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/5.x/testing/index.md PHP code demonstrating a test method using the jsonApi() helper. It builds a GET request for /api/v1/posts, specifies the expected resource type ('posts') and includes relationships ('author', 'tags'). It then uses assertFetchedOneExact to compare the response against an expected resource object. Requires the MakesJsonApiRequests trait. ```php public function test(): void { $expected = // ... our expected posts resource object. $response = $this ->jsonApi() ->expects('posts') ->includePaths('author', 'tags') ->get('/api/v1/posts'); $response->assertFetchedOneExact($expected); } ``` -------------------------------- ### Publishing JSON:API Configuration - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/getting-started/index.md Executes the Artisan command to publish the default configuration file for the Laravel JSON:API package. This creates `config/jsonapi.php`, allowing customization of the package's settings. ```bash php artisan vendor:publish --provider="LaravelJsonApi\Laravel\ServiceProvider" ``` -------------------------------- ### Sending Invalid Paged GET Request - HTTP Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/08-fetching-resources.md An example HTTP GET request to fetch 'posts' resources with invalid query parameters. Specifically, it attempts to use a `page[size]` value (150) that exceeds the configured validation rule's maximum limit (100). This request is intended to trigger a validation error from the API endpoint. ```http GET http://jsonapi-tutorial.test/api/v1/posts?page[number]=1&page[size]=150 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Equivalent HTTP Request for page() Example Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/requests.md Shows the resulting HTTP GET request with the `page` query parameters correctly formatted based on the array provided to the `page()` method. ```http GET /api/v1/posts?page[number]=1&page[size]=10 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Requiring Testing Package Dev Composer Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/getting-started/index.md Adds the `laravel-json-api/testing` package as a development-only dependency using Composer. It provides test helpers for writing JSON:API tests. Requires Composer and a Laravel project. ```bash composer require --dev laravel-json-api/testing:^1.1 ``` -------------------------------- ### Equivalent HTTP Request for filter() Example Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/requests.md Shows the resulting HTTP GET request with the `filter` query parameter correctly formatted based on the array provided to the `filter()` method. ```http GET /api/v1/posts?filter[published]=true HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Create JSON:API Server Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/tutorial/03-server-and-schemas.md Generates a new JSON:API server class using the Artisan command. This creates the file `app/JsonApi/V1/Server.php`, which serves as the central configuration point for the 'v1' API. ```bash vendor/bin/sail artisan jsonapi:server v1 ``` -------------------------------- ### Equivalent HTTP Request for sparseFields() Example Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/requests.md Shows the resulting HTTP GET request with the `fields` query parameter correctly formatted for the specified resource types and their requested fields. ```http GET /api/v1/posts?fields[posts]=title,slug,author&fields[users]=name HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Running Database Seed Command | Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/2.x/tutorial/02-models.md This command executes the overall database seeding process configured in the `DatabaseSeeder`. It will run the included `PostSeeder`, populating the database tables (users, tags, posts, comments) with the defined data. ```bash vendor/bin/sail artisan db:seed ``` -------------------------------- ### Equivalent HTTP Request for includePaths() Example Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/3.x/testing/requests.md Shows the resulting HTTP GET request with the `include` query parameter correctly formatted based on the paths provided to the `includePaths()` method. ```http GET /api/v1/posts?include=author,tags HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Client Request for WhereNotIn Filter (Array) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client excludes resources using the 'WhereNotIn' filter with multiple values for the same filter key. ```http GET /api/v1/posts?filter[not-category]=foo&filter[not-category]=bar HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Run Posts Database Seeder Laravel Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/tutorial/08-fetching-resources.md Command-line instruction using Laravel Artisan via the 'herd' helper to execute the `PostsSeeder` class specifically, triggering the database seeding process to create fake users and posts as defined in the seeder's `run` method. ```bash herd php artisan db:seed --class PostsSeeder ``` -------------------------------- ### Client Request for WhereIdNotIn Filter (Delimiter) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client excludes multiple resources using the 'WhereIdNotIn' filter with a comma-separated string of IDs. ```http GET /api/v1/posts?filter[exclude]=3,9 HTTP/1.1 Accept: application/vnd.api+json ``` -------------------------------- ### Execute Posts Seeder - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/tutorial/08-fetching-resources.md Uses the Sail wrapper for the Artisan command-line tool to run the `PostsSeeder` class, populating the database with the generated fake users and posts. ```Bash vendor/bin/sail artisan db:seed --class PostsSeeder ``` -------------------------------- ### Installing Laravel JSON:API Packages - Bash Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/4.x/getting-started/index.md Installs the core `laravel-json-api/laravel` package and the recommended `laravel-json-api/testing` package as a development dependency using Composer. These packages are required to build JSON:API compliant applications with Laravel. ```bash composer require laravel-json-api/laravel composer require --dev laravel-json-api/testing ``` -------------------------------- ### Client Request for WhereIdIn Filter (Delimiter) Source: https://github.com/poolitclub/laravel-json-api.github.io/blob/develop/docs/1.x/schemas/filters.md This snippet shows an example HTTP GET request where a client requests multiple resources using the 'WhereIdIn' filter with a comma-separated string of IDs. ```http GET /api/v1/posts?filter[id]=3,9 HTTP/1.1 Accept: application/vnd.api+json ```