Search by

websk / php-crud

websk

CRUD

Package info

github.com/websk/php-crud

pkg:composer/websk/php-crud

Statistics

Installs: 320

Dependents: 4

Suggesters: 0

Stars: 1

Open Issues: 2

4.0.1 2026-10-26 17:32 UTC

README

CRUD forms, tables, filters and widgets for WebSK applications based on Slim 4 and PHP-DI.

Requirements

  • PHP 8.3 or newer, including PHP 8.5
  • Composer 2
  • PHP extensions: fileinfo, json, mbstring, pdo
  • Node.js 24 LTS and npm 11 when rebuilding the demo frontend assets

Install

https://packagist.org/packages/websk/php-crud

Install the package with Composer:

composer require websk/php-crud

Config

CRUD requires no package-specific configuration. Register CRUDServiceProvider in a mutable PSR-11 container. PHP-DI 7 applications can use MutableContainerAdapter while registering legacy WebSK service providers.

Development

Run all PHP checks with:

composer check

This command runs syntax checks, PHPUnit and PHPStan at level max.

Build static demo assets with:

npm ci
npm run build
npm run check
npm run audit:production
npm run audit:high

The build copies an explicit set of browser files from node_modules into the ignored public/assets/libraries directory. npm run check checks the asset-manifest JavaScript, verifies every declared source asset, rejects server-side files anywhere under public/assets, compares the local assets with a temporary rebuild, and runs the documented frontend behavior baseline in a real Chromium browser. Install the Playwright browser once with npx playwright install chromium; set PLAYWRIGHT_CHANNEL=chrome to use an installed Google Chrome. audit:production fails on any production advisory of moderate severity or higher; audit:high checks the complete dependency tree for high and critical findings.

With the Docker demo running, use PLAYWRIGHT_CHANNEL=chrome npm run test:browser:docker to exercise the real user list and edit routes, create popup, Ace editor and remote multiple autocomplete. The check edits controls in the browser without saving entities.

The demo and generated CRUD markup use Bootstrap 5.3.8. Native browser date controls are used by the CRUD date, date-time and timestamp widgets, so Moment and Bootstrap Datetimepicker are no longer required. MediumEditor, Blueimp File Upload and Tokenize2 are served from generated local assets; the demo no longer relies on third-party frontend CDNs. Shared form, popup and filter rules are generated as /assets/libraries/crud/crud.css. Applications consuming websk/php-crud must publish that file together with the npm-managed library assets and include it after Bootstrap or their Bootstrap-based theme styles.

The canonical Bootstrap script is /assets/libraries/bootstrap/js/bootstrap.bundle.min.js. The build also keeps /assets/libraries/bootstrap/js/bootstrap.min.js as a compatibility alias and publishes the referenced Bootstrap JavaScript and CSS source maps, so browser developer tools do not request missing .map files.

Generated form rows and visible filters associate their captions with the first usable control. Popup create forms expose dialog semantics and move focus to their first control. Required fields are highlighted after validation, and clickable table rows retain a single accessible link.

Demo

  • Install mkcert.

  • Initialize its local CA:

    mkcert --install
  • Create a local certificate for php-crud.devbox:

    mkcert php-crud.devbox
  • Copy the generated certificate and key to var/docker/nginx/sites using the names referenced by the nginx configuration.

  • Add the host to /etc/hosts, or %WINDIR%\System32\drivers\etc\hosts on Windows:

    127.0.0.1 php-crud.devbox
    
  • Create the local application configuration and adjust it if needed:

    cp config/config.example.php config/config.php
  • Enter the Docker directory:

    cd var/docker
  • Create the local environment file and adjust it if needed:

    cp .example.env .env
  • Build and start the containers. The PHP-FPM image uses PHP 8.5:

    docker compose up -d --build
  • Install project dependencies:

    docker compose exec php-fpm composer install
  • Run database migrations:

    docker compose exec php-fpm php vendor/bin/websk_db_migration.php migrations:migration_auto

    Or run migrations interactively:

    docker compose exec php-fpm php vendor/bin/websk_db_migration.php migrations:migration_handle
  • Build static assets:

    npm ci
    npm run build
    npm run check
    npm run audit:production
    npm run audit:high
  • Open https://php-crud.devbox.

License

This project is licensed under the MIT License.