PHP code example of monken / cli-create

1. Go to this page and download the library: Download monken/cli-create 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/ */

    

monken / cli-create example snippets


 namespace App\Controllers;


class User extends BaseController
{
    public function index()
    {
        echo 'Hello World!';
    }
}

 namespace App\Controllers;

use CodeIgniter\Controller;

class User extends Controller
{
    public function index()
    {
        echo 'Hello World!';
    }
}

 namespace App\Controllers;

use App\Models\Api\InfoModel;
use App\Models\UserModel;

class Member extends BaseController
{
    public function index()
    {
        echo 'Hello World!';
    }
}

 namespace App\Controllers\System\Admin;

use CodeIgniter\Controller;

class Login extends Controller
{
    public function index()
    {
        echo 'Hello World!';
    }
}


 namespace App\Controllers;

use CodeIgniter\RESTful\ResourceController;

class User extends ResourceController
{
    
    protected $modelName = 'App\Models\User';
    protected $format    = 'json';

    public function index(){
        return $this->respond([
            "status" => true,
            "msg" => "index method successful."
        ]);
    }
    
    /*****/

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');

//CliCreate-add-in-2020-04-10 05:42:27
$routes->resource('user',[
    'controller' =>'\App\Controllers\User',
]);


 namespace App\Controllers\System\Api;

use CodeIgniter\RESTful\ResourceController;

class User extends ResourceController
{
    
    protected $modelName = 'App\Models\User';
    protected $format    = 'json';

    public function index(){
        return $this->respond([
            "status" => true,
            "msg" => "index method successful."
        ]);
    }

    /*********/


/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');

//CliCreate-add-in-2020-04-10 05:49:09
$routes->resource('api/user',[
    'controller' =>'\App\Controllers\System\Api\User',
]);


//CliCreate-add-in-2020-04-10 05:54:38
$routes->resource('user',[
    'controller' =>'\App\Controllers\User',
    'websafe' => 1,
]);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');

//CliCreate-add-in-2020-04-10 05:59:28
$routes->resource('user',[
    'controller' =>'\App\Controllers\User',
    'only' => ['index','show','create','update','delete'],
]);


 namespace App\Controllers;

use App\Models\BlogModel;

class Blog extends BaseController
{
    public function index()
    {
        echo 'Hello World!';
    }
}

 namespace App\Models;

use CodeIgniter\Model;

class BlogModel extends Model
{
    protected $table      = '';
    protected $primaryKey = 'id';

    protected $returnType = 'array';
    protected $useSoftDeletes = true;

    protected $allowedFields = ['Field1', 'Field2'];

  /*********/


 namespace App\Controllers;

use CodeIgniter\Controller;
use App\Models\NoticeModel;

class Notice extends Controller
{
    public function index()
    {
        echo 'Hello World!';
    }
}

 namespace App\Models;

use CodeIgniter\Model;

class NoticeModel extends Model
{
    protected $table      = '';
    protected $primaryKey = 'id';

    protected $returnType = 'array';
    protected $useSoftDeletes = true;

    protected $allowedFields = ['Field1', 'Field2'];

  /*********/


 namespace App\Controllers;

use App\Models\BlogModel;

class Blog extends BaseController
{
    public function index()
    {
        echo 'Hello World!';
    }
}


 namespace App\Models;

use CodeIgniter\Model;

class BlogModel extends Model
{
    protected $DBGroup = 'default';
}

 namespace App\Controllers\System\Api;

use CodeIgniter\RESTful\ResourceController;

class User extends ResourceController
{
    
    protected $modelName = 'App\Models\UserModel;
';
    protected $format    = 'json';

    public function index(){
        return $this->respond([
            "status" => true,
            "msg" => "index method successful."
        ]);
    }
/********/

 namespace App\Models;

use CodeIgniter\Model;

class User extends Model
{
    protected $table      = 'users';
    protected $primaryKey = 'id';

    protected $returnType = 'array';
    protected $useSoftDeletes = true;

    protected $allowedFields = ['Field1', 'Field2'];

    protected $useTimestamps = false;

 namespace App\Models;

use CodeIgniter\Model;

class User extends Model
{
    protected $DBGroup = 'group_name';
}

 namespace App\Models;

use CodeIgniter\Database\ConnectionInterface;

class User
{
    protected $db;

    public function __construct(ConnectionInterface &$db)
    {
        $this->db =& $db;
    }
}

 namespace App\Models;

use CodeIgniter\Model;

class User extends Model
{
    protected $table         = 'users';
    protected $allowedFields = [
        'Filed1', 'Filed2'
    ];
    protected $returnType    = 'App\Entities\User';
    protected $useTimestamps = true;
}

 namespace App\Entities;

use CodeIgniter\Entity;

class User extends Entity
{
    //
}

 namespace App\Models\Api\System;

use CodeIgniter\Model;

class User extends Model
{
    //...
}

php spark list

    $ php spark create:controller [controller_name] [Options]
    

$ php spark create:contorller [controller_name]

$ php spark create:controller [controller_name] -nobase

$ php spark create:controller [controller_name] -usemodel

php spark create:controller [controller_name] -rest

$ php spark create:model [model_name]

$ php spark create:model [model_name] -basic

$ php spark create:model [model_name] -manual