Overview
There are many reasons why you might want to install Statamic into an existing Laravel application. You could use Statamic to:
- handle all the marketing and "logged out" content for a SaaS app
- add an easy-to-manage blog the whole team can update
- manage existing data kinda like Laravel Nova (yes, you can do that),
- run as a headless CMS and provide a REST API to your data
- be a special comfort package for those tough projects even when you don't need it
Supported Versions of Laravel
Laravel 8 and Laravel 9 are supported. It feels like this section needs more than one sentence but it really doesn't. That first one said all that needs saying.
Install Statamic
There are 3 steps to follow to install Statamic into your Laravel app.
-
Run
php artisan config:clear
to make sure your config isn't cached. -
Add the
statamic:install
command topost-autoload-dump
incomposer.json
."scripts": {"post-autoload-dump": ["Illuminate\\Foundation\\ComposerScripts::postAutoloadDump","@php artisan package:discover --ansi","@php artisan statamic:install --ansi","@php artisan statamic:search:update --all --ansi","@php artisan statamic:static:clear --ansi"],} -
Install
statamic/cms
with Composer.composer require statamic/cms --with-dependencies
Regarding Users
If you want to continue to keep users in a database, head over to Storing Users in a Database in an Existing Laravel App follow those steps.
Otherwise, the Storing User Records page should have instructions for the most common scenarios.
New Statamic Directories
After Statamic is installed, you'll have 3 new directories in your project:
-
content/
, -
resources/users/
-
config/statamic/
Statamic relies on a "catch-all" wildcard route to handle its URLs. Any explicitly defined routes in your application will take precedence over those handled by Statamic. Be sure that you don't have your own catch-all route or else nothing will ever be passed off to Statamic.