LENKRAD - The modern PHP core
Basics
Advanced
Deployment

CLI Basics

Basic CLI commands

Basic CLI commands

The cli is a powerful helper for your fast-paced reality. If you have a setup similar as described in quick-start, you should have a working cli execution via php cli. The tool is extendable and customizable, so here we are going to focus on an introduction of the most useful and common commands:

Command
Description

list

Lists all available and registered commands

create:model {FullyQualifiedNameSpace}

Creates a model in the specified namespace

create:controller {FullyQualifiedNameSpace}

Creates a routable in the specified namespace

create:request {FullyQualifiedNameSpace}

Creates a request guard in the specified namespace

migrate:model {mysql | sqlite} {FullyQualifiedNameSpace} [-o {output-folder}] [--with-copy]

Migrates a model towards the database. Additionally, a dump (copy) and a migration file (if output folder is set) can be generated

migrate:models {mysql | sqlite} {NameSpaceToExplore} [-o {output-folder}] [--with-copy]

Same as above, but the plural indicates that every model within the specified namespace gets migrated.

Example (assuming MySql setup)

  1. php create:model App\Models\Comment
  2. Specify properties in generated file as described in Models
  3. php migrate:model mysql App\Models\Comment
Unlike other frameworks, LENKRAD doesn't require separate migration files. If edge-cases create ambiguities (for example when renaming existing properties), data is always left intact and a copy of the previous structure can be consulted.

Before you move on

Many references on this page assume default settings. Your project might differ in behavior, paths etc.