# Installation

> Install Laravel Rest Api in a Laravel application, publish its configuration and add the optional packages.

## Requirements

- PHP **8.3** or higher
- Laravel **13.30** or higher

Applications on Laravel 12 stay on version 2.x. An application on an earlier Laravel 13 release updates Laravel first:

```bash
composer update laravel/framework
```

## Installing the package

Install the package with Composer:

```bash
composer require lomkit/laravel-rest-api
```

The service provider and the `Rest` facade register themselves through Laravel's package discovery.

Publish the configuration file when you want to change a default:

```bash
php artisan vendor:publish --tag=rest-config
```

This writes `config/rest.php`. Every key is described in [Configuration](/getting-started/configuration). The package merges its defaults into your file at every level, so you can keep only the keys you change.

## Optional packages

The package works without them. Install them for the features they bring:

<table>
<thead>
  <tr>
    <th>
      Package
    </th>
    
    <th>
      Version
    </th>
    
    <th>
      Brings
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        laravel/sanctum
      </code>
      
       or <code>
        laravel/passport
      </code>
    </td>
    
    <td>
      any
    </td>
    
    <td>
      Token authentication for the routes that <code>
        rest:quick-start
      </code>
      
       adds
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dedoc/scramble
      </code>
    </td>
    
    <td>
      <code>
        ^0.13.48
      </code>
    </td>
    
    <td>
      The OpenAPI document of every endpoint, see <a href="/digging-deeper/openapi">
        OpenAPI
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        laravel/scout
      </code>
    </td>
    
    <td>
      <code>
        ^11.9
      </code>
    </td>
    
    <td>
      Text search on a search engine, see <a href="/search/search-engines">
        Search engines
      </a>
    </td>
  </tr>
</tbody>
</table>

```bash
composer require dedoc/scramble:^0.13.48
```

<note>

Composer refuses a Scramble release outside `0.13.48` to `0.13.x`, and a Scout release below `11.9`, next to the package.

</note>

## Setting up your first resources

The quickest way to get started is the `rest:quick-start` command. It asks which models to expose, then writes their resources, controllers, policies and routes, behind authentication:

```bash
php artisan rest:quick-start
```

Follow the [Quick start](/getting-started/quick-start) to see what it writes and to send your first requests. To write a resource by hand, see [Resources](/resources/resources).

## Upgrading from 2.x

Version 3.0 changes the declarations of resources, the payloads and the responses. Read the [Upgrade guide](/getting-started/upgrade-guide) before you update the package.
