hydrat / grogu-cms
Quickly mount a Content Management System on top of Filament on Laravel. Chose your front stack, or go Headless.
Fund package maintenance!
Hydrat
Requires
- php: ^8.1
- bezhansalleh/filament-language-switch: ^3.0
- filament/filament: ^3.0
- filament/spatie-laravel-media-library-plugin: ^3.1
- filament/spatie-laravel-settings-plugin: ^3.1
- hydrat/filament-table-layout-toggle: ^1.1
- illuminate/contracts: ^10.0
- jeffgreco13/filament-breezy: ^2.2
- lorisleiva/laravel-actions: ^2.7
- spatie/eloquent-sortable: ^4.2
- spatie/laravel-package-tools: ^1.15.0
- spatie/laravel-permission: ^6.3
- vormkracht10/laravel-seo-scanner: ^3.10
Requires (Dev)
- nunomaduro/collision: ^7.9
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-04-13 18:33:28 UTC
README
This package brings CMS features to Laravel, based on top of Filament, as a drop-in replacement for Wordpress. It is designed to be used with a front-end stack of your choice, or as a headless CMS. The package brings pre-defined resources to manage your content, settings pages, and a set of SEO tools to help you optimize your content for search engines.
While the package helps you defining your models Resources, It also comes with a predefined panel so you can also quickly get up and running.
Features :
- Page/Post/Model management :
- Status
- Slug
- Excerpt
- Thumbnail
- Templates
- Flexible content blocks
- Hierarchical structure (parent/child)
- Custom "post types", configured via Blueprints and Template classes to avoid bloated models
- SEO tools (meta title, meta description, meta tags, sitemap, structured data, SEO checks)
- Menus
- Settings pages
- Users and Permissions management
- Multilingual dashboard
- You keep control on your models, migrations, routes, and views
- Native front-end support for blade, livewire, inertia
Screenshots
Installation
You can install the package via composer:
composer require hydrat/grogu-cms
You can publish and run the migrations with:
php artisan vendor:publish --tag="grogu-cms-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="grogu-cms-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="grogu-cms-views"
This is the contents of the published config file:
return [
];
In addition, to setup dependancies, you will need to run the following commands:
php artisan seo:install
If using a Javascript front-end, such as Vue or React, you will also need to install puppeteer :
npm install puppeteer
Then, of your public models you will need to enable Javascript on SEO checks :
<?php namespace App\Models; use App\Cms\Models\Contracts\Resourceable; use App\Cms\Models\CmsModel; use Vormkracht10\Seo\Facades\Seo; use Vormkracht10\Seo\SeoScore; class Page extends CmsModel implements Resourceable { public function seoScore(): SeoScore { return Seo::check(url: $this->url, useJavascript: true); } }
Please read the laravel-seo-scanner documentation for more details.
Usage
Defining your models
You can easily create a model using the make:cms-model
command :
php artisan make:cms-model Page
Basically, this model will be a regular Eloquent model, extending the CmsModel
class :
<?php namespace App\Models; class Page extends CmsModel { /** * @var string<BlueprintContract> */ protected static string $blueprintSchema = \App\Cms\Blueprints\PageBlueprint::class; }
The Blueprint is where the model configuration will happen. You can generate this file automatically by adding the --blueprint
option to the make:cms-model
command, or using the make:cms-blueprint
command :
php artisan make:cms-blueprint PageBlueprint
Blueprints helps GroguCMS by telling how to handle your model. It will :
- Define the front-end route to a single model (when applicable)
- Define the front-end view to use, when using our Controller helpers
- Enable/Disable features such as SEO, Exceprt, Content...
- Define templates and flexible layouts
- Define if the model is hierarchical
Rendering your models
Create the routes
First, you need to create the route to your pages. Here, we define the root path to use FrontPageController, as it will read the settings defined on the admin panel.
Route::get('/', Web\FrontPageShowController::class)->name('front-page.show'); Route::get('/{slug}', Web\PageShowController::class)->where('slug', '(.*)')->name('pages.show');
Using blade/livewire
Using inertia
When using Inertia, it is likely that you will want to filter the data sent to the browser. To do so, GroguCMS automatically convert your model to a JsonResource before sending it to the browser.
First, create a resource for your model :
php artisan make:resource PageResource
Then, add the Resourceable
contract to your model, and implement the toResource
method :
<?php namespace App\Models; use App\Cms\Contracts\Resourceable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations; use Illuminate\Http\Resources\Json\JsonResource; class Page extends Model implements Resourceable { public function toResource(): JsonResource { return new \App\Http\Resources\PageResource($this); } }
You can then configure your resource as needed.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.