alexeyplodenko / sitecode
Filament v4 basic CMS like plugin. Adds pages management with page structure defined in .php files.
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/alexeyplodenko/sitecode
Requires
- php: ^8.2
- ext-mbstring: *
- filament/filament: ^4|^5
- prettus/l5-repository: ^3
README
Filament v4 and v5 basic CMS like plugin. Adds pages management with page structure defined in .php files.
Installation
- Run
composer require alexeyplodenko/sitecode. - Create the following directories and give PHP write and web server read permissions:
/public/media/for image and file uploads/public/sitecode_static_cache/for pages cache
- Create a public disk, if you need to edit images and files in Sitecode. Go to
/config/filesystems.php, add the following to the'disks'array:'sitecode_public_media' => [ 'driver' => 'local', 'root' => public_path('media'), 'url' => env('APP_URL').'/media', 'visibility' => 'public', 'throw' => true, 'report' => true, ],
- Register the plugin in Filament AdminPanelProvider
/app/Providers/Filament/AdminPanelProvider.php:<?php namespace App\Providers\Filament; use Filament\Panel; use Filament\PanelProvider; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel // ... ->plugin(\Alexeyplodenko\Sitecode\SitecodePlugin::make()); // <-- Add this line } }
- Run
php artisan sitecode:installto install cache feature. - Run
php artisan migrateto create DB tables to store data.
Usage
For example, we have the following Blade file /resources/views/home.blade.php:
<!DOCTYPE html> <html lang="en"> <head> <title>My Website</title> </head> <body> <main> <h1>My page title</h1> <p>My page content goes here...</p> <div> <img src="/my-image.jpg" alt=""> </div> </main> </body> </html>
To make the content editable with Sitecode, create a file /resources/views/home.admin.php next to original text.blade.php file, with:
<?php $pageFields = new \Alexeyplodenko\Sitecode\Models\PageFields(); $pageFields->makeField('Title'); $pageFields->makeField('Text')->setEditorWysiwyg(); $pageFields->makeField('Image')->setEditorFile(); return $pageFields;
and then adjust the initial Blade file /resources/views/home.blade.php:
@php /** @var \Alexeyplodenko\Sitecode\Models\Page $page */ @endphp <!DOCTYPE html> <html lang="en"> <head> <title>{{ $page->title }}</title> </head> <body> <main> @if ($page->hasContent('Title')) <h1>{{ $page->getContent('Title') }}</h1> @endif {!! $page->getContent('Text') !!} <div> <img src="{{ $page->getContent('Image') }}" alt=""> </div> </main> </body> </html>
Now go to Filament installation in your browser (by default at http://localhost/admin), and add your fist page in Pages. You want to create a page with our created home.blade.php view created before.
Here is the website page and its content:
Here are the page properties:
The list of pages:
Special cases
Custom admin. panel domain
Define your custom admin. panel domain as SITECODE_ADMIN_URL=https://admin.example.com in /.env file, when the domain is different from your website domain.
Custom disk name
Define your custom filesystem disk name as SITECODE_DISK=sitecode_public_media in /.env file, if you do not want to use the default one.
Issues you might face
Disk [sitecode_public_media] does not have a configured driver.
You have missed the step 3 from the Installation section of this document.


