The easy, flexible and scalable API-first Laravel CMS package:
It can be installed into any existing Laravel application.
Run this command within your Laravel application directory:
composer req aimeos/laravel-cms
php artisan cms:install --seed
If you don't want to add any demo pages, remove the --seed
option.
To allow existing users to edit CMS content or to create a new users if they don't exist yet, you can use the cms:user
command (replace the e-mail address by the users one):
php artisan cms:user editor@example.com
To disallow users to edit CMS content, use:
php artisan cms:user --disable editor@example.com
To clean up soft-deleted pages, contents and files regularly, add these lines to the schedule()
method in your app/Console/Kernel.php
class:
$schedule->command('model:prune', [
'--model' => [
\Aimeos\Cms\Models\Page::class,
\Aimeos\Cms\Models\Version::class,
\Aimeos\Cms\Models\Content::class,
\Aimeos\Cms\Models\File::class],
])->daily();
You can configure the timeframe after soft-deleted items will be removed permantently by setting the cms.purge option. It's value must be the number of days after the items will be removed permanently or FALSE if the soft-deleted items shouldn't be removed at all.
Using multiple page trees with different domains is possible by changing the cms.page
route in your ./routes/web.php
to:
Route::group(['domain' => '{domain}'], function() {
Route::get('{slug?}/{lang?}', [\Aimeos\Cms\Http\Controllers\PageController::class, 'index'])->name('cms.page');
});
The domain
property in the pages must then match the request domain.
Laravel CMS supports single database multi-tenancy using existing Laravel tenancy packages or code implemented by your own.
The Tenancy for Laravel package is most often used. How to set up the package is described in the tenancy quickstart and take a look into the single database tenancy article too.
Afterwards, tell Laravel CMS how the ID of the current tenant can be retrieved. Add this code to the boot()
method of your \App\Providers\AppServiceProvider
in the ./app/Providers/AppServiceProvider.php
file:
\Aimeos\Cms\Tenancy::$callback = function() {
return tenancy()->initialized ? tenant()->getTenantKey() : '';
};
If you want to integrate Laravel CMS into another application, you may want to grant access based ony your own authorization scheme. You can replace the Laravel CMS permission handling by adding your own function. Add this code to the boot()
method of your \App\Providers\AppServiceProvider
in the ./app/Providers/AppServiceProvider.php
file:
\Aimeos\Cms\Permission::$callback = function( string $action, ?\App\Models\User $user ) : bool {
if( /* check access */ ) {
return true;
}
return false;
};
The first parameter is the action access is requested for, e.g. "page:view" while the second parameter is the user object if authenticated. By default, permissions of CMS users are checked against the authorization bitmap from the cmseditor
column of their user object from the Laravel users
table. The function must return TRUE to grant access or FALSE if access is denied.
Available actions which access can be granted to are: