We’re going to install Statamic to use as a CMS into our existing Laravel application. By default Statamic will use the same authentication as the existing application, but we want to use the built-in Statamic authentication and not the current application’s authentication.
You should start by installing Statamic using composer. You can see the detailed instructions here: https://statamic.dev/installation#exising-laravel
Now that Statamic is installed, let’s configure it.
After installing, Statamic will use the ‘eloquent’ driver for the authentication. In order to use the default Statamic driver, we’ll have to change this to ‘statamic’.
The first step is to add the Statamic guard and provider in `config/auth.php`
// config/auth.php 'guards' => [ ... 'statamic' => [ 'driver' => 'session', 'provider' => 'statamic', ] ], ... 'providers' => [ ... 'statamic' => [ 'driver' => 'statamic', ], ]
The second step is to change the users config for Statamic. You can change it by editing the config/statamic/users.php file.
// config/statamic/users.php 'guards' => [ 'cp' => 'statamic', // the guard when using the CP -> thus the Statamic admin 'web' => 'web', // the guard when using Statamic frontend routes -> if you want everyone to be able to access your pages just use the 'web' ],
You can find out more about customising the authentication here: Using an Independent Authentication Guard
P.S. Don’t forget to make an user: php please make:user
That’s it! Now you can sign in to the Statamic control panel separately from your web app.