Download the PHP package m4rc/reut_cli without Composer
On this page you can find all versions of the php package m4rc/reut_cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download m4rc/reut_cli
More information about m4rc/reut_cli
Files in m4rc/reut_cli
Package reut_cli
Short Description REUT CLI Tool - A lightweight PHP framework with model-based database management
License MIT
Homepage https://github.com/m4rcTr3y/Reut-Cli
Informations about the package reut_cli
REUT Backend Framework
REUT is a lightweight PHP framework that streamlines web development with intuitive routing, database management, and authentication.
Built on Slim PHP for routing, REUT uses JWT (JSON Web Tokens) for secure authentication and introduces a model-based approach to database interaction—define your data structure in a PHP class, and REUT automatically generates CRUD APIs and manages tables for you.
Features
- Slim PHP Routing: Fast, flexible routing powered by Slim.
- Model-Based Database Management: Define tables as PHP classes in the
modelsdirectory—no manual SQL required. - Automatic CRUD API: Default CRUD endpoints for each model.
- Built-in Authentication: Ready-to-use login, register, refresh, and logout endpoints with JWT tokens (can be disabled via
REUT_AUTH_ENABLED=false). - File Upload Handling: Manages file uploads defined in model fields.
- Customizable Routes: Add custom routes in the
routersdirectory, with optional authentication middleware. - Runtime API Docs: Built-in
/docsendpoint (HTML or JSON) lists every registered route and can be disabled viaREUT_DOCS_ENABLED=false. - Configurable Setup: Set database connection details in
.envorconfig.php. - Advanced Migration System (v1.3.0+):
- Dry-run mode: Preview migrations before executing (
--dry-runflag) - Rollback support: Rollback migrations by batch or specific migration
- Migration validation: Validate SQL syntax and detect conflicts before applying
- Export/Import: Export and import migration history for backup or sharing
- Enhanced status: JSON output, summary mode, and table-specific status checks
- Protected columns: Automatic protection of common columns (
created_at,updated_at, etc.)
- Dry-run mode: Preview migrations before executing (
Installation
Prerequisites
- PHP: 7.4 or higher
- Composer: getcomposer.org
- Git: (optional)
1. Install the REUT CLI Tool
Install globally via Composer:
2. Add Composer's vendor/bin to Your PATH
Linux/macOS
Composer may use either the traditional location (~/.composer) or the XDG location (~/.config/composer). Check which one you're using:
For traditional location (~/.composer):
Edit your shell config:
- Bash/Zsh:
~/.bashrcor~/.zshrc - Fish:
~/.config/fish/config.fish
For XDG location (~/.config/composer):
Edit your shell config:
- Bash/Zsh:
~/.bashrcor~/.zshrc - Fish:
~/.config/fish/config.fish
Fish shell specific:
Add to ~/.config/fish/config.fish:
Reload your shell:
Verify installation:
Windows
- Edit your user
Pathvariable in Environment Variables. - Add:
%APPDATA%\Composer\vendor\bin - Open a new terminal and run:
Troubleshooting Stability Errors
If you see a stability error, install the development version:
Note: Current version (
v1.4.9). See Packagist.
Updating REUT CLI
Update to the latest version with a single command:
This automatically clears the composer cache and updates to the latest version.
05115002be09fb060fda8bfaf23480d356f0937c
3. Initialize a New REUT Project
Create a new project:
You’ll be prompted for:
- Project name (default:
myproject) - Database type (
mysqlorpostgresql) - Database name (default:
test_db) - Database username (default:
root) - Database password (optional)
- Secret key (default:
12345678)
This sets up your project directory with all necessary files.
4. Set Up Your Project
Navigate to your project:
Install dependencies:
Generate models or resources:
Usage
-
Initialize a project (run anywhere):
-
Project directory commands (run inside your project folder):
- Global CLI commands (if installed globally):
API Docs Endpoint
- Visit
/docsin your running project to see a generated list of all registered routes (CRUD + custom). Append?format=jsonfor JSON output. - Set
REUT_DOCS_ENABLED=falsein.envto skip registering the docs endpoint (recommended for production).
Custom Routes & Documentation
-
Import
Reut\Router\ReuteRouteinside your router classes; it wraps Slim’s router and auto-records metadata for/docs. - Generated routers already use
ReuteRoute, so CRUD endpoints appear automatically. Custom routes simply adopt the helper to stay documented.
Migration Commands (v1.3.0+)
REUT CLI provides comprehensive migration management:
Basic Migration Commands
migrate/create: Apply migrations from models to database. Creates tables, adds columns, and respects protected columns.sync: Aggressively reconcile database with models. Can drop columns and orphan tables (use with caution).status: Check pending migrations without applying them. Supports--json,--summary, and--tableoptions.
Advanced Migration Features
-
rollback: Undo migrations -
validate-migrations: Check migration SQL syntax and detect conflicts -
export-migrations: Export migration history to JSON or SQL -
import-migrations: Import migration history from JSON or SQL file -
Dry-run mode: Preview changes before executing
- Enhanced status: Get detailed migration information
See MIGRATION_COMMANDS.md for detailed documentation on all migration commands.
Built-in Authentication
-
REUT provides ready-to-use authentication endpoints when enabled (default during
Reut init):POST /auth/login- Login with email/username and password, returns JWT token and refresh tokenPOST /auth/register- Register new user accountPOST /auth/refresh- Refresh JWT token using refresh tokenPOST /auth/logout- Revoke tokens
-
Configuration via
auth.php(generated during init): -
Auto-creates default
Userstable if no custom auth model exists (whenauto_create_tableis enabled). -
Disable authentication endpoints by setting
REUT_AUTH_ENABLED=falsein.env. - Extend
Reut\Auth\AuthControllerto customize validation, password hashing, or response formatting:
Defining Relationships
-
Define foreign keys directly inside your model classes using
addForeignKey, e.g.: - Each call automatically marks the table as relational and contributes to the relationship count so migrations know to create parent tables first.
Disabled Routes
-
Control which CRUD routes are generated for each model using the
disabledRoutesarray in the model constructor: - Route options:
'all'- Disables all CRUD routes (useful for read-only models)'find'- DisablesGET /{model}/find/{id}'add'- DisablesPOST /{model}/add'update'- DisablesPUT /{model}/update/{id}'delete'- DisablesDELETE /{model}/delete/{id}
- Disabled routes are automatically excluded from route generation and shown in the schema viewer at
/schema.
Per-Model Authentication
-
Enable authentication for specific models by setting
requiresAuthtotruein the model constructor: - When
requiresAuthistrue:- All CRUD endpoints for that model require a valid JWT token
- The
Authorization: Bearer <token>header must be included in requests - Auth status is displayed in the schema viewer at
/schema
- When
requiresAuthisfalse(default):- Routes are publicly accessible without authentication
-
This allows fine-grained control: some models can be public while others require authentication.
- The viewer command copies the
/viewerfolder into new projects and serves it with the built-in PHP server so you can inspect tables visually. - Use
Reut dev --port=9000 --host=0.0.0.0(orphp manage.php dev) to spin up a PHP dev server with the bundled router that falls back toindex.php.
Troubleshooting
- Command not found: Ensure Composer's
vendor/binis in your PATH. - Stability error: Use
m4rc/reut_cli:dev-mainor check Packagist for updates. - Missing files: Ensure your project includes required templates and source files. Contact the maintainer if issues persist.
- Runtime errors: Run commands with
--verbosefor more details. - Environment configuration: Set
APP_ENV=developmentfor development orAPP_ENV=productionon live servers to hide detailed stack traces and enable production optimizations (caching, tighter error logging). Never run with debug mode enabled in public environments.
Contributing
Contributions welcome! Submit issues or pull requests at GitHub.
License
MIT License.