PHP Classes

File: examples/plain/README.md

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   Caelrik   examples/plain/README.md   Download  
File: examples/plain/README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Caelrik
Build Web user interface from PHP components
Author: By
Last change:
Date: 8 days ago
Size: 2,140 bytes
 

 

Contents

Class file image Download

Plain PHP example

Grid (server-side, 250 rows), Chart, Scheduler, Form, an article form with a rich text editor and uploads, and Tabs, a Modal and Notifications, without any framework.

composer install
npm install && npm run build
php -S localhost:8000 examples/plain/index.php

Open <http://localhost:8000>.

  • `/people.json` is the Grid endpoint. It accepts DataTables parameters and the simple format, for example `/people.json?page=2&per_page=5&sort=-name&search=paris`.
  • The Scheduler loads `/events.json?start=?&end=?` and posts changes as JSON to `/events/create`, `/events/update` and `/events/delete` with the `X-CSRF-TOKEN` header (see `calendar.php`). Events are kept in the session.
  • The article form (`article.php`) uploads files to `/upload/cover` and `/upload/attachments` (FilePond: POST returns an id, DELETE reverts). On submit, `/article` claims the ids, sanitizes the editor HTML with `EditorHtml::sanitize()`, and shows the result. Files are stored in the system temp directory, outside the web root.
  • `ui.php`: Tabs remember the selected tab in the URL hash. The newsletter form lives in a Modal: on a validation error the page reopens the modal (`open()`); on success it redirects and shows a Notification from the session flash.
  • `files.php`: a File Manager on a folder in the system temp directory. The connector is `/files/connector`, and elFinder's assets are served from `vendor/studio-42/elfinder` under `/elfinder/`. This demo only authorizes requests from this computer.
  • `theme-builder.php`: the ThemeBuilder at `/theme-builder`, previewing this page's form, grid, tabs and chart (only from this computer). Save keeps the theme in the session; `/?custom=1` shows the example with it (`/custom-theme.css` is `Theme::toCss()`).
  • Dark mode: add `?mode=dark`. The links at the top of the page switch between light, dark and the saved theme.
  • The form posts to `/contact`. Server-side errors are shown with Bootstrap feedback, and the CSRF token is checked with `hash_equals`.
  • Bootstrap and jQuery come from a CDN here. Caelrik's own bundle is served from `public/` under `/assets/`.