PHP code example of naf / cms

1. Go to this page and download the library: Download naf/cms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

naf / cms example snippets


return [
    'naf/cli',
    'naf/database',
    'naf/session',
    'naf/form',
    'naf/view',
    'naf/i18n',
    'naf/orm',
    'naf/queue',
    'naf/schedule',
    'naf/mail',
    'naf/mcp',
    'naf/cms',
];

// app/config.php
return [
    'database' => [
        'driver' => 'sqlite',
        'database' => BASE_PATH . '/storage/nafcms.sqlite',
    ],
];

return [
    'cms' => [
        'runtime_path' => 'storage/nafcms',
    ],
];

use Naf\CMS\Enums\Permission;
use Naf\CMS\Page\Page;
use function Naf\View\view;

cms()->pages()->add(
    Page::create('plugin.reports')
        ->setPath('/admin/reports')
        ->setTitle('Reports')
        ->setLayout('admin')
        ->

Page::create('plugin.reports')
    ->setPath('/admin/reports')
    ->setAdminNavigation('Reports', parent: 'content', icon: 'stats', key: 'plugin.reports');

use Naf\CMS\Enums\Scope;
use Naf\CMS\Navigation\NavigationItem;

cms()->scope(Scope::ADMIN)->navigation()->add(
    NavigationItem::create('plugin.reports')
        ->setLabel('Reports')
        ->setHref('/admin/reports')
        ->setParent('content')
        ->setIcon('stats')
);

use Naf\CMS\Contracts\MediaStorageInterface;
use App\Media\S3MediaStorage;
use function Naf\app;

app()->container()->set(
    MediaStorageInterface::class,
    static fn(): MediaStorageInterface => new S3MediaStorage(),
);

use Naf\CMS\Events\CmsEvent;
use Naf\CMS\Events\ContentEvent;
use function Naf\event;
use function Naf\log;

event()->listen(CmsEvent::PAGE_PUBLISHED, fn (ContentEvent $e) => log()->info('Page published', ['pageId' => $e->subjectId]));
event()->listen(CmsEvent::ARTICLE_PUBLISHED, [ClearCacheListener::class, 'handle']); // built through the container