# Getting Started with Laravel

This integration guide is following the Quick Start Guide. We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this url (opens new window).

Should you wish to use standalone PHP, you may also be interested in the PHP integration guide.

This guide assumes you already have Laravel installed (opens new window) and are familiar with the basics of the framework.

# Install the Laravel-Strapi Laravel Package

composer require dbfx/laravel-strapi

This will install Laravel-Strapi (opens new window), a Laravel specific package for interacting with Strapi.

You will also need to define your STRAPI_URL and STRAPI_CACHE_TIME in the .env file:

STRAPI_URL=http://localhost:1337
STRAPI_CACHE_TIME=3600

# Get your collection type

Execute a GET request on the restaurant Collection Type in order to fetch all your restaurants.

Be sure that you activated the find permission for the restaurant Collection Type.

Request

$strapi = new Dbfx\LaravelStrapi();
$restaurants = $strapi->collection('restaurants');

You may now iterate over the $restaurants array which will contain all your restaurants. More options are available as well:

$restaurants = $strapi->collection('restaurants', $sortKey = 'id', $sortOrder = 'DESC', $limit = 20, $start = 0, $fullUrls = true);

# Accessing single type items

You may also access Single Type items as follows:

$strapi = new Dbfx\LaravelStrapi();

// Fetch the full homepage array
$homepageArray = $strapi->single('homepage');

// Return just the ['content'] field from the homepage array
$homepageItem = $strapi->single('homepage', 'content');

# Collection by field

$strapi = new Dbfx\LaravelStrapi();
$entries = $strapi->entriesByField('restaurants', 'slug', 'test-restuarant-name');

# Single item from collection

$strapi = new Dbfx\LaravelStrapi();
$entry = $strapi->entry('restaurants', $id = 5);

# Conclusion

Here is how to request your Collection Types in Strapi using PHP. When you create a Collection Type or a Single Type you will have a certain number of REST API endpoints available to interact with.

There is more documentation available in the README (opens new window) or in the PHP integration guide.