1. Go to this page and download the library: Download preflow/folio 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/ */
// config/folio.php: the app's default guard stays the employers'
return ['path' => '/folio', 'guard' => 'staff'];
namespace App\Folio\Overrides\Content;
use Preflow\Folio\Override\OverridableAction;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
final class Index implements OverridableAction
{
public function handle(ServerRequestInterface $request): ResponseInterface
{
// your custom dashboard
}
}
try {
$publisher->saveDraft($record, (int) $body['_version']);
} catch (VersionConflict $e) {
// show the conflict; $e->current is the version to save against
}
try {
$publisher->saveDraft($record, (int) $body['_version']);
$publisher->publish($record, $userId, (int) $record->get('_version'));
} catch (VersionConflict $e) {
// someone saved in between; nothing was published
}
// app/Folio/Demo/Extension.php
#[FolioExtension(name: 'demo', label: 'Demo', description: 'A screen, a note customization and a setting', icon: 'ui-puzzle', version: '1.0.0')]
#[DeclaresPermission('demo.view', 'See the demo screen')]
#[DeclaresPermission('demo.shout', 'Shout a note')]
final class Extension extends \Preflow\Folio\Extension\Extension
{
public function settings(): array
{
return [
'greeting' => ['type' => 'string', 'label' => 'Greeting', 'default' => 'Hello from the demo extension'],
];
}
}
public function seed(Container $c): array
{
$c->get(RoleStore::class)->ensure('staff', 'shop_manager', 'Shop manager', ['shop.view', 'shop.refund']);
return []; // lines to print, one each
}
// app/Folio/Demo/Screens/Overview.php
#[FolioScreen('demo', 'Demo overview', icon: 'ui-file', permission: 'demo.view')]
final class Overview
{
public function __construct(private readonly DataManager $data) {}
#[Get('/')]
public function index(): ScreenView
{
return new ScreenView('@demo/overview.twig', [
'notes' => $this->data->queryType('note')->get()->items(),
]);
}
}
#[FolioScreen('demo', 'Demo overview', permission: 'demo.view', assets: ['demo.css', '@folio/htmx.js'])]
final class Overview
{
#[Get('/')]
public function index(): ScreenView
{
// listed after the attribute's assets; a file named in both is
// app/Folio/Demo/Types/NoteTweaks.php
#[FolioType('note')]
final class NoteTweaks
{
public function __construct(private readonly DataManager $data) {}
#[FormPanel('Name length')]
public function nameLength(DynamicRecord $record): string
{
return mb_strlen((string) $record->get('name')) . ' characters';
}
#[RecordAction('shout', 'Shout', 'demo.shout', icon: 'ui-check', confirm: 'Upper-case this note\'s name?')]
public function shout(DynamicRecord $record): null
{
$record->set('name', mb_strtoupper((string) $record->get('name')));
$this->data->saveType($record, false);
return null;
}
}
#[FormPanel('Decision', position: 'side')]
public function decision(DynamicRecord $record): ScreenView
{
return new ScreenView('@members/decision.twig');
}
#[RecordAction('accept', 'Accept', 'members.decide', toolbar: false)]
public function accept(DynamicRecord $record, ServerRequestInterface $request): null { /* ... */ }
#[RecordAction('decline', 'Decline', 'members.decide', toolbar: false)]
public function decline(DynamicRecord $record, ServerRequestInterface $request): null { /* ... */ }
#[ListColumn('State')]
public function state(DynamicRecord $record): Badge
{
return new Badge('Waiting', 'changed');
}
'greeting' => ['type' => 'string', 'label' => 'Greeting', 'default' => 'Hello from the demo extension'],
$settings = $container->get(\Preflow\Folio\Extension\Settings\ExtensionSettings::class);
$settings->get('demo', 'greeting'); // the stored value, else the default, else null
$settings->get('demo', 'greeting', 'de'); // translatable fields: a locale (falls back like content)
$settings->get('demo', 'greeting', 'de', exact: true); // only de's own value or default, never another locale's
php preflow folio:pull production --dry-run # what would change
php preflow folio:pull production # backup, then replace local content
php preflow folio:pull production --only=data # records only (or --only=media)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.