> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fetchski-attract.com/llms.txt
> Use this file to discover all available pages before exploring further.

# The Laravel SDK

> Every route of this API, one or two lines from a Laravel app.

Any call is one or two lines through the `Attract` facade: nothing to import beyond it, nothing to
catch, and a test of it is three lines. The SDK handles the rest.

> [card] [fetchski/attract-cms-laravel](https://docs.fetchski-attract.com/laravel/installation.md)
>
> Laravel 12 or 13 · PHP 8.5.12+ · Guzzle 7.10+ or 8.3+

```php Call it theme={"dark"}
use Fetchski\AttractCmsLaravel\Facades\Attract;

$post = Attract::blogPosts()->getBlog(id: $id);   // $post->title, $post->publishedAt
```

```php Test it theme={"dark"}
Attract::fake();
Attract::blogPosts()->getBlog(id: 'example-id');
Attract::assertCalled('blogPosts.getBlog');
```

```bash Scaffold it theme={"dark"}
php artisan make:attract-action blogPosts.getBlog
```

## What it does for you

> [card] Typed answers
>
> Readonly objects with properties: Collections, Carbon dates, PHP enums. No null checks on what the
> site always sends.

> [card] Nothing to catch
>
> Laravel's handler logs and renders every failure; a refused value is a normal validation error.

> [card] Safe retries
>
> Rate limits waited out; reads retried when the site doesn't answer.

> [card] Whole lists
>
> `…All()` walks every page as a `LazyCollection`, however the list pages.

> [card] Three-line tests
>
> `Attract::fake()`, a factory for every model, and `assertCalled`.

> [card] Artisan tools
>
> Scaffold an Action, list every method, call one from the CLI, check a site.

## The guides

**1. Installation**

Install it from your own site, then into your app. [Install the SDK →](https://docs.fetchski-attract.com/laravel/installation.md)

**2. Configuration**

One site from `.env`, more by hand, or a table. [Configure →](https://docs.fetchski-attract.com/laravel/configuration.md)

**3. Calling the API**

Arguments, answers, lists, jobs and uploads. [Make calls →](https://docs.fetchski-attract.com/laravel/calling-the-api.md)

**4. Errors, paging and testing**

[Errors](https://docs.fetchski-attract.com/laravel/errors.md) · [Paging](https://docs.fetchski-attract.com/laravel/paging.md) · [Testing](https://docs.fetchski-attract.com/laravel/testing.md)

## Artisan commands

Install the SDK into your app: publish the config, write the site's URL, key and signing secret to
`.env`, and check the site ([Installation](https://docs.fetchski-attract.com/laravel/installation.md)):

```bash Terminal theme={"dark"}
php artisan attract:install
```

Or keep the key encrypted in the package's `attract_api_keys` table instead of `.env`
([Key in the database](https://docs.fetchski-attract.com/laravel/key-in-database.md)):

```bash Terminal theme={"dark"}
php artisan attract:install --database
```

Store or replace the key in that table:

```bash Terminal theme={"dark"}
php artisan attract:store-key
```

Swap a stored key for a new one from the site's CMS:

```bash Terminal theme={"dark"}
php artisan attract:rotate-key
```

Delete the stored key from that table:

```bash Terminal theme={"dark"}
php artisan attract:forget-key
```

Scaffold an Action for any method, and its test, in the app or a module (add `--module=<Name>` or
`--app`):

```bash Terminal theme={"dark"}
php artisan make:attract-action blogPosts.getBlog
```

List every method of an accessor, with its HTTP route and purpose:

```bash Terminal theme={"dark"}
php artisan attract:list blogPosts
```

Call any method on the real site and print the answer:

```bash Terminal theme={"dark"}
php artisan attract:call blogPosts.listBlogs perPage=5
```

Check the config, the site, the key and the clock:

```bash Terminal theme={"dark"}
php artisan attract:check
```

Call every read the site offers and report what broke:

```bash Terminal theme={"dark"}
php artisan attract:sweep
```

> [card] [Every command, with its options](https://docs.fetchski-attract.com/laravel/artisan-commands.md)
>
> What each command does, when to use it, and examples to copy.

## The reference

Every method has its own page in this tab's sidebar, grouped like the API reference.

> [card] The call, ready to copy
>
> One or two lines, pinned beside the page.

> [card] Its arguments
>
> Named arguments with their types, a body's fields among them.

> [card] What it returns
>
> Each property of the answer, typed, with nested models one click away.

> [card] Its test and its Action
>
> A three-line fake, and the Artisan line that scaffolds the Action.

> [card] [Start with Pages → List](https://docs.fetchski-attract.com/laravel/reference/pages/list-pages.md)
>
> The first method in the reference.

> [!NOTE]
>
> Your own site serves the package: any of its API keys installs it, no other account needed.
> Using TypeScript? See the [TypeScript SDK](https://docs.fetchski-attract.com/typescript/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.