Download the PHP package idei/usim without Composer

On this page you can find all versions of the php package idei/usim. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package usim

USIM — UI Services Implementation Model

A Server-Driven UI framework for Laravel. Define your entire user interface in PHP — screens, menus, forms, tables, modals — and let the framework render, diff, and update everything automatically on the client.

Table of Contents


Requirements

Dependency Version
PHP ^8.2
Laravel 10.x / 11.x / 12.x / 13.x
laravel/sanctum ^3.0 / ^4.0
spatie/laravel-permission ^6.0
symfony/finder ^6.0 / ^7.0
nikic/php-parser ^5.7
symfony/var-dumper ^6.0 / ^7.0
illuminate/contracts ^10.0 / ^11.0 / ^12.0 / ^13.0

What Is New Since 0.6.0 (v0.7.0)

For the full release details, see CHANGELOG.md.


Installation

Laravel's package auto-discovery will register UsimServiceProvider automatically.

Quick Start

Run the install command to scaffold a complete working application with authentication, profile, menus, configuration, and routes:

Then follow the printed instructions:

Starting the Application

The ./start.sh script uses RoadRunner instead of Laravel's artisan serve command. This is necessary because artisan serve is single-threaded and does not properly support the framework's concurrent execution requirements.

Usage

Note:

Visit http://localhost:8000 — you have a working USIM app.

Use --force to overwrite existing files.


Core Concepts

Screens

A Screen is a PHP class that defines a full page. Each screen extends Screen and builds its UI inside buildBaseUI():

Screen Operational Model

In USIM, treat a Screen as a stateful backend UI service, not as a passive template:

This model keeps backend as the source of truth and avoids business-logic duplication across client and server.

Important clarification: USIM does not register one Laravel route per Screen class. Instead, it uses a catch-all web route plus a generic /api/ui/{screen} loader and resolves URL <-> Screen class through naming convention.

After creating the file, register it:

Then visit /hello-screen in your browser.

UI — The Component Factory

UI is a static factory that creates component builders. Every builder uses a fluent API:

Event Handlers

When a button fires an action (e.g. ->action('save_form')), the framework calls a handler method on the same screen class. The convention is on + PascalCase action name:

Action string Handler method
save_form onSaveForm(array $params)
delete_item onDeleteItem(array $params)
navigate_home onNavigateHome(array $params)

The $params array contains all current component values (inputs, selects, checkboxes, etc.) from the client.

State Management

Screen state is server-side. The framework automatically:

  1. Builds the UI tree on first load
  2. Stores the serialized state
  3. On events, restores state → runs your handler → diffs old vs new → sends only the delta to the client

Properties prefixed with store_ are persisted across requests and mirrored on the client as part of the USIM storage payload.

Persistence is now plain by default:

Use _crypt only when the value should not be readable from client storage.


Available Components

Factory Method Builder Class Description
UI::label() Label Text labels, headings, paragraphs
UI::button() Button Action buttons with styles
UI::input() Input Text, email, password, hidden inputs
UI::select() Select Dropdown selects
UI::checkbox() Checkbox Checkboxes and toggles
UI::form() Form Form grouping
UI::table() Table Data tables with pagination
UI::card() Card Cards with title, description, actions
UI::container() Container Layout container (vertical/horizontal/grid) with card() / plain() appearance and optional server-driven tabs
UI::menuDropdown() MenuDropdown Navigation dropdown menus
UI::uploader() Uploader File upload with preview and crop
UI::calendar() Calendar Calendar/date picker
UI::carousel() Carousel Media carousel for image/audio/video with manual/auto modes
UI::split() Split Resizable/collapsible split panel layout
UI::timer() Timer Autonomous timer for polling, delays, and scheduled events

Builders share a fluent API across UIComponent and Container with common methods like:


Screens in Depth

Creating a Screen

  1. Create a class in app/UI/Screens/ (or a subdirectory):

  2. Run discovery:

  3. Visit /products/list — the URL is automatically derived from the namespace path.

Screen Discovery

USIM uses Symfony Finder to scan the configured screens directory and generates a manifest cache:

The manifest maps URL slugs to screen classes using a CRC32-based offset system for deterministic component IDs.

Authorization

Override authorize() to control access:

When authorization fails, the framework automatically redirects to login (for guests) or shows a 403 (for insufficient permissions).

Menu Integration

Screens integrate with the navigation menu via static methods:

Then in your Menu screen, use $menu->screen(MyScreen::class) for automatic linking with permission checks:

Lifecycle Hooks

Method When
buildBaseUI($container) Called on first load to build the initial UI tree
postLoadUI() Called after state is restored — update components with live data
onResetScreen() Called when ?reset=true is passed in the URL

Component auto-injection: If you declare a typed property with the same name as a component ID, USIM automatically injects the builder instance. For example, protected Input $input_name; will be populated with the input created as UI::input('input_name').


Event System

Handling Button Actions

Cross-Service Events

Emit events that ALL active screen services receive using UsimEvent:

Any screen with a matching handler will react:


Built-in UI Helpers

Available inside any Screen handler:

Labels can now render raw HTML or an existing Blade view:

Most components also support anchor-based positioning helpers for floating or pinned UI:


Database Translations

USIM now supports package-level database translations with key-based identifiers and language fallback.

Published migration stubs create these tables:

The TranslationService manages CRUD for languages, keys, and values (including optional media fields).

Global utility helper:

Resolution order:

  1. current locale in DB
  2. fallback locale in DB (en by default)
  3. key literal

Translation values support placeholders (:name, :count, etc.) and optional media metadata (media_url, media_meta).

Auto-key behavior for human-readable text (t('Some text')):

I18n suggestion logging:

Recommended key naming for package and scaffolded code:

When adding or changing scaffold text, prefer t('...') with one of the namespaces above and include the key in UsimTranslationSeeder.


Modals & Dialogs

Quick Confirmation Dialogs

Use ConfirmDialog for standard dialogs:

Dialog types: INFO, CONFIRM, WARNING, ERROR, SUCCESS, CHOICE, TIMEOUT.

Custom Modals

Build custom modal content using any component and set ->parent('modal'):


Data Tables

For paginated server-side data tables, extend AbstractTableModel:

Then use it in your screen:


File Uploads

Use the Uploader for file uploads with temporary storage, preview, and image cropping:

In your event handler, confirm the upload to move it from temporary to permanent storage:

Temporary uploads are automatically cleaned up hourly via a scheduled job.


Image placeholders

An Image without a src receives a generated placeholder by default. The default generator creates an SVG locally using the component caption and configured colors. Its dimensions use pixel-sized width/height when provided, or the configured placeholder dimensions; AspectRatio fills in a missing dimension:

For images saved by USIM's upload flow, storage() resolves a relative filename with UploadService::fileUrl(). Absolute URLs and root-relative paths remain unchanged:

placeholderId() provides a stable identity for seeded image services. To use Picsum, set USIM_IMAGE_PLACEHOLDER_GENERATOR to Idei\Usim\Services\ImagePlaceholders\PicsumImagePlaceholderGenerator; the URL uses the configured seed prefix and the same identity to return a stable image. To integrate another image API (including one requiring an API key), implement ImagePlaceholderGeneratorInterface and configure its fully-qualified class in USIM_IMAGE_PLACEHOLDER_GENERATOR, or bind that interface in the application.

The available .env settings are USIM_IMAGE_PLACEHOLDER_ENABLED, USIM_IMAGE_PLACEHOLDER_WIDTH, USIM_IMAGE_PLACEHOLDER_HEIGHT, USIM_IMAGE_PLACEHOLDER_BACKGROUND, USIM_IMAGE_PLACEHOLDER_TEXT_COLOR, and USIM_IMAGE_PLACEHOLDER_SEED_PREFIX. An explicit src always takes precedence; an action-based image shows its placeholder while the request is in progress. fallback() remains the separate behavior for a source that fails to load.


Authentication Scaffolding

php artisan usim:install provides a complete authentication and admin system:

Screen Path Description
Login /auth/login Email/password login with Sanctum tokens
ForgotPassword /auth/forgot-password Send password reset link via email
ResetPassword /auth/reset-password Reset password form
EmailVerified /auth/email-verified Email verification handler
Profile /auth/profile User profile (name, photo, password change)
Admin\UsersManager /admin/dashboard User management table with CRUD and role assignment (admin only)

Supporting files:

Default Users (via .env)

After install, configure your .env:

The installer now provisions the default access data during php artisan usim:install; no separate package seeder is required.


Testing Screens

This package ships a self-contained testing guide under docs/:

Recommended workflow:

  1. Read the guide to follow the project conventions (uiScenario, component-level assertions, response contracts).
  2. Use docs/tests_prompt.md as a base when delegating test generation to an AI agent.
  3. Validate locally with php artisan test (or file-level execution first).

Core approach used across this project:


Core Contracts & Mockable Architecture

USIM is decoupled from the host application using Dependency Inversion (DIP). The core package never depends on host models like App\Models\User or concrete database libraries directly. Instead, it relies on strict interfaces in Idei\Usim\Contracts:

Interface Namespace Purpose
AuthorizableActorInterface Idei\Usim\Contracts Entities that can be checked for permissions (getAuthIdentifier())
UsimUserInterface Idei\Usim\Contracts User profile representation (getEmail(), getName())
PairableActorInterface Idei\Usim\Contracts Kiosk and physical device actor abstraction (isPaired(), getPairingIdentifier())
ScreenAuthorizerInterface Idei\Usim\Contracts Evaluates permissions/roles for screens without tight coupling to Spatie or DB
UnitsServiceInterface Idei\Usim\Contracts Contract for organizational units synchronization
UnitContextResolverInterface Idei\Usim\Contracts Resolves active operational unit slugs
UnitSyncResult Idei\Usim\Contracts Readonly, strongly-typed result DTO for unit synchronizations

In-Memory Testing with Mocks

Because screens authorize via ScreenAuthorizerInterface, you can test authorization in unit tests without database migrations, seeds, or Spatie permissions:


Configuration

Publish the config file (done automatically by usim:install):

This creates config/usim.php:

Key Description Default
front_store_key Unique application identifier used to scope persisted UI storage keys my-app (override via FRONT_STORE_KEY)
screens_namespace PSR-4 namespace where screens live App\UI\Screens
screens_path Filesystem path to scan for screens app/UI/Screens
api_url Base URL for internal HTTP calls APP_URL
upload_disk Laravel filesystem disk for uploaded files local (override via UPLOAD_DISK)
users.roles Role metadata and default seeded users admin / user roles scaffold
i18n.default_locale Preferred locale for DB translation lookup APP_LOCALE or en
i18n.fallback_locale Fallback locale for DB translations en

Headless Mode

USIM can run in headless mode, serving API endpoints only without requiring a web renderer.

Configuration

Set the environment variable:

Behavior

Example (Node.js/JavaScript Client)

Example (PHP Client)



API Endpoints

USIM registers these routes automatically:

Method URI Description
GET /api/ui/{screen} Load a screen (returns JSON UI tree)
POST /api/ui-event Handle an event (returns JSON diff)
POST /api/upload/temporary Upload a file to temporary storage
DELETE /api/upload/temporary/{id} Remove a temporary upload
GET /files/{path} Serve uploaded files

The client-side JavaScript (ui-renderer.js) handles these calls automatically.


Artisan Commands

Command Description
php artisan usim:discover Scan screens directory and generate manifest cache
php artisan usim:install Scaffold a complete USIM application (screens, auth, admin, tests)
php artisan usim:install --force Overwrite existing files

Octane / RoadRunner Support

USIM is compatible with long-running processes. The service provider automatically resets the component ID generator on each request when laravel/octane is detected:

The UIChangesCollector is registered as a scoped singleton, ensuring clean state per request.


Directory Structure

After usim:install, your application will have:

The package itself lives in vendor/idei/usim/ (or packages/idei/usim/ during development).


License

MIT


All versions of usim with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
laravel/sanctum Version ^3.0|^4.0
symfony/finder Version ^6.0|^7.0|^8.0
symfony/yaml Version ^6.0|^7.0|^8.0
nikic/php-parser Version ^5.7
symfony/var-dumper Version ^6.0|^7.0|^8.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package idei/usim contains the following files

Loading the files please wait ...