PHPackages                             puko/console - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. puko/console

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

puko/console
============

Advanced console util that make pukoframework get things done on the fly.

0.4.0(1y ago)25.8k1MITPHPPHP &gt;=7.0|&gt;=8.0

Since Nov 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Velliz/pukoconsole)[ Packagist](https://packagist.org/packages/puko/console)[ RSS](/packages/puko-console/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)DependenciesVersions (15)Used By (1)

Puko Console
============

[](#puko-console)

Advanced CLI utility that makes the **Puko Framework** development experience faster and more efficient.

Installation
------------

[](#installation)

```
composer require puko/console --dev
```

Requirements
------------

[](#requirements)

- PHP 7.2.5+
- Symfony Console 5.4
- Supported Databases: MySQL, PostgreSQL, SQL Server

Usage
-----

[](#usage)

```
php puko  [options] [arguments]
```

Quick Start
-----------

[](#quick-start)

```
# Show version
php puko --version

# Show help
php puko --help

# List all commands
php puko list
```

---

Commands
--------

[](#commands)

### Setup Commands

[](#setup-commands)

CommandDescription`setup:db [schema]`Connect to database and generate models`setup:secure`Generate encryption configuration`setup:auth `Generate authentication plugin`setup:controller  `Generate controller (view or service)`setup:model   `Interactive model wizard#### Examples

[](#examples)

```
# Setup database
php puko setup:db main

# Generate encryption config
php puko setup:secure

# Generate auth plugin
php puko setup:auth UsersAuth

# Generate controller
php puko setup:controller view HomeController
php puko setup:controller service UserService

# Create model (interactive)
php puko setup:model add User main
```

---

### Routes Commands

[](#routes-commands)

CommandDescription`routes:list`List all registered routes`routes:resort`Sort routes alphabetically`routes:dir`Display routes with directories`routes:view  `Add view route`routes:service  `Add service (API) route`routes:crud `Generate full CRUD service`routes:console  `Add console route`routes:socket  `Add WebSocket route`routes:error `Set error handler`routes:lost `Set 404 handler#### Examples

[](#examples-1)

```
# List routes
php puko routes:list

# Add view route
php puko routes:view add /home

# Add service route
php puko routes:service add /api/users

# Generate CRUD for table
php puko routes:crud main/users
```

---

### Generate Commands

[](#generate-commands)

CommandDescription`generate:db`Create database from models (reverse engineer)`generate:ui`Generate DataTables UI components#### Examples

[](#examples-2)

```
# Reverse engineer: create DB from models
php puko generate:db

# Generate UI components
php puko generate:ui
```

---

### Refresh Commands

[](#refresh-commands)

CommandDescription`refresh:db [schema]`Reload database schema and regenerate models```
php puko refresh:db main
```

---

### Other Commands

[](#other-commands)

CommandDescription`serve [port]`Start PHP built-in server (default: 4000)`language `Build localization files`element:add `Generate view element`element:download `Download element from repository`cli `Execute PHP in console mode`tests`Run PHPUnit tests#### Examples

[](#examples-3)

```
# Start server
php puko serve
php puko serve 8080

# Build language files
php puko language controller/user

# Create element
php puko element:add DataTable

# Run tests
php puko tests
```

---

Options
-------

[](#options)

OptionDescription`-h, --help`Display help for a command`-q, --quiet`Do not output any message`-V, --version`Display application version`--ansi`Force ANSI output`--no-ansi`Disable ANSI output`-n, --no-interaction`Do not ask interactive questions`-v, -vv, -vvv`Increase verbosity---

Project Structure
-----------------

[](#project-structure)

After using Puko Console, your project will have:

```
project/
├── config/
│   ├── database.php      # Database configuration
│   ├── routes.php         # Route definitions
│   ├── encryption.php     # Security config
│   └── init.php          # Console config
├── controller/           # Service controllers
├── plugins/
│   ├── auth/             # Authentication plugins
│   ├── controller/       # View controllers
│   ├── elements/        # UI elements
│   └── model/            # Model definitions
├── model/                # Model contracts
├── assets/
│   ├── html/             # HTML templates
│   ├── scripts/          # JavaScript files
│   ├── ui/               # UI components
│   └── master/           # Localization files
└── tests/
    └── unit/             # Unit tests

```

---

PHPDoc Annotations
------------------

[](#phpdoc-annotations)

Puko Console uses PHPDoc annotations for model introspection:

```
/**
 * #Table users
 */
class Users extends Model
{
    /**
     * #Column id
     * #PrimaryKey
     */
    public $id = 0;

    /**
     * #Column name
     * #VarChar(100) not null
     */
    public $name = '';
}
```

### Supported Annotations

[](#supported-annotations)

- `#Table [name]` - Table name
- `#Column [name]` - Column definition
- `#PrimaryKey` - Primary key field
- `#VarChar(size)`, `#Int`, `#Text`, etc. - Data types

---

Migration Commands
------------------

[](#migration-commands)

Database migration system supporting MySQL, PostgreSQL, and SQL Server.

CommandDescription`migrate:make `Create new migration file`migrate:run`Run pending migrations`migrate:rollback`Rollback last migration`migrate:reset`Rollback ALL migrations`migrate:status`Show migration status### Migration Make Options

[](#migration-make-options)

OptionDescription`--create`Create a new table`--table`Specify table name### Examples

[](#examples-4)

```
# Create migration for new table
php puko migrate:make create_users_table
php puko migrate:make create_users_table --create users

# Create migration to modify existing table
php puko migrate:make add_email_to_users_table --table users

# Run all pending migrations
php puko migrate:run

# Run specific number of migrations
php puko migrate:run --step=3

# Rollback last migration
php puko migrate:rollback

# Rollback multiple migrations
php puko migrate:rollback --step=2

# Rollback ALL migrations
php puko migrate:reset

# Check migration status
php puko migrate:status
```

### Migration File Structure

[](#migration-file-structure)

```
