# Getting Started with Laravel
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 need to publish a config file:
php artisan vendor:publish --provider="Dbfx\LaravelStrapi\LaravelStrapiServiceProvider" --tag="strapi-config"
You will also need to define your
STRAPI_CACHE_TIME in the
# Get your collection type
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.
Example GET 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);
Here is how to request your Collection Types in Strapi using Laravel. When you create a Collection Type or a Single Type you will have a certain number of REST API endpoints available to interact with.