Using Strapi and Laravel

What is Laravel

What is Strapi

STRAPI VS LARAVEL

Setting up a Strapi Project

npx create-strapi-app strapilara --quickstart
yarn develop

Creating Strapi Colleaction

Setting the permission

Setting Up Laravel Project

composer create-project laravel/laravel lara
cd lara
php artisan serve

Connecting Laravel and Strapi

composer require dbfx/laravel-strapi
STRAPI_URL=http://localhost:1337
STRAPI_CACHE_TIME=3600
//php
<?php
return [
'url' => env('STRAPI_URL'),
'cacheTime' => env('STRAPI_CACHE_TIME', 3600),
];
//php
use Dbfx\LaravelStrapi\LaravelStrapi;
//php
Route::get('/test', function () {
$strapi = new LaravelStrapi();
return $blogs = $strapi->collection('blogs');
});
//php
Route::get('/test/{id}', function ($id) {
$strapi = new LaravelStrapi();
return $blogs = $strapi->entry('blogs', $id);
});

Where You Could Go from Here

php artisan make:controller BlogController
php artisan serve
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BlogController extends Controller
{
//
}
public function blog()
{
return view('blog');
}
Route::get('/blog', [BlogController::class, 'blog']);
//php
<?php
namespace App\Http\Controllers;
use Dbfx\LaravelStrapi\LaravelStrapi;
use Illuminate\Http\Request;
class BlogController extends Controller
{
public function blog()
{
$strapi = new LaravelStrapi();
$blogs = $strapi->collection('blogs');
return view('blog', compact(['blogs']));
}
}

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Strapi

Strapi

2.1K Followers

The open source Headless CMS Front-End Developers love.