PHP code example of puko / console

1. Go to this page and download the library: Download puko/console library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

puko / console example snippets


/**
 * #Table users
 */
class Users extends Model
{
    /**
     * #Column id
     * #PrimaryKey
     */
    public $id = 0;
    
    /**
     * #Column name
     * #VarChar(100) not null
     */
    public $name = '';
}



use pukoconsole\migration\Schema;
use pukoconsole\migration\Blueprint;

class CreateUsersTable
{
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::drop('users');
    }
}

// Column types
$table->id();                    // Primary key auto-increment
$table->bigId();                 // Bigint primary key
$table->string('name', 100);     // VARCHAR
$table->text('description');      // TEXT
$table->integer('age');          // INT
$table->bigInteger('quantity'); // BIGINT
$table->decimal('price', 8, 2); // DECIMAL
$table->boolean('active');      // BOOLEAN/TINYINT
$table->date('created_at');      // DATE
$table->dateTime('updated_at');  // DATETIME
$table->timestamp('expires_at'); // TIMESTAMP
$table->binary('data');          // BLOB
$table->json('options');         // JSON
$table->uuid('uuid');            // UUID

// Modifiers
$table->string('name')->nullable();       // Allow NULL
$table->string('name')->default('Anon'); // DEFAULT value
$table->string('email')->unique();       // UNIQUE constraint
$table->integer('votes')->unsigned();    // UNSIGNED
$table->primary();                        // Primary key

// Special
$table->foreignId('user_id')->references('id')->on('users');
$table->timestamps();     // created_at and updated_at
$table->softDeletes();   // deleted_at


return [
    'version' => '1.0.0',
    'repo' => 'https://api.github.com/repos/velliz/puko-elements/contents'
];
bash
php puko <command> [options] [arguments]
bash
# 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
bash
# Reverse engineer: create DB from models
php puko generate:db

# Generate UI components
php puko generate:ui
bash
php puko refresh:db main
bash
# 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