Search by

crabphp / crab

bangnokia

There is no license information available for the latest version (v0.2.1) of this package.

A starting point for an application on the Crab framework

Package info

github.com/crabphp/crab

Type:project

pkg:composer/crabphp/crab

Statistics

Installs: 13

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.1 2026-11-12 19:28 UTC

This package is auto-updated.

Last update: 2026-11-12 19:28:20 UTC


README

A starting point for an application on the Crab framework.

Start

composer create-project crabphp/crab shop
cd shop
php cua dev

create-project copies .env.example to .env and writes a new secret, APP_KEY, into it with php cua key:generate. From a clone of this repository instead, run composer install, cp .env.example .env and php cua key:generate before php cua dev.

Open http://127.0.0.1:8080. The server restarts when you save a file. php cua lists every command, php cua describe prints the whole application for coding agents, and composer test runs the tests.

It needs PHP 8.4 with mbstring, pdo_sqlite, pcntl and posix. Development also needs dom and xmlwriter, for PHPUnit, which runs the tests; create-project checks for them even with --no-dev. A production install, composer install --no-dev, does not.

On Windows

Develop inside WSL 2, not in PowerShell or the Command Prompt: the server uses PHP's pcntl and posix extensions, which PHP for Windows does not have. In PowerShell opened as administrator, run wsl --install and restart Windows. Then, in the Ubuntu terminal it installs:

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt install -y php8.4-cli php8.4-mbstring php8.4-xml php8.4-sqlite3 unzip

Install Composer from getcomposer.org/download and move it into place with sudo mv composer.phar /usr/local/bin/composer. Then run the commands under Start from your Linux home folder (cd ~), not from /mnt/c, and open http://localhost:8080 in your browser on Windows.

Developing on Windows in the framework's guide explains each step.

Where things are

app.php                      describes the application: plugins, routes, middleware
routes/web.php               HTTP routes
routes/console.php           your commands
app/Actions/                 route actions as classes
app/Setup.php                your services
config/                      settings, read from .env; config('file.key') reads one
storage/                     logs and the SQLite file; never committed
tests/                       tests that send the application requests, without a server
AGENTS.md                    the conventions, for coding agents

Making things

To add Run
A command php cua make:command PruneUsers, which writes it and registers it as user:prune
Middleware php cua make:middleware RequireAdmin
A table php cua make:migration create_posts_table, then php cua migrate; php cua migrate:fresh starts the database over
A setting the framework has php cua config:publish server writes every server setting, at its default

The database is SQLite in storage/database.sqlite until you set DB_DRIVER=mysql and DB_DATABASE (with DB_HOST, DB_USERNAME and DB_PASSWORD) in .env.

In production

APP_DEBUG=false
APP_URL=https://api.example.com
SERVER_WORKERS=4

Then php cua start --daemon, with php cua reload after each deploy and php cua stop to stop. See Deployment.

The guide

Every topic has a page in the framework's guide, which comes with it too, in vendor/crabphp/framework/docs/.