diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b42743..ce27d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,26 @@ All notable changes to the "codeigniter4-snippets" extension will be documented in this file. -Check [Keep a Changelog](https://github.com/adereksisusanto/codeigniter4-snippets/releases/tag/0.0.9) for recommendations on how to structure this file. +Check [Keep a Changelog](https://github.com/adereksisusanto/codeigniter4-snippets/releases/tag/0.1.0) for recommendations on how to structure this file. ## Donate If this project help you reduce time to develop, you can give me a cup of coffee :) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/adereksisusanto?locale.x=id_ID) [![Donate](https://img.shields.io/badge/Donate-trakteer.id-red)](https://trakteer.id/adereksisusanto) +## [Released - 0.1.0] - 2021-09-21 + +- #### Fixed Bugs Snippets. +- #### Update Snippets. + - [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md) + - [Controller Resources](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md#controller-resources) +- #### Add New Snippets. + - [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md) + - [Controller Presenter](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md##controller-presenter) + - [Routes](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md) + - [Placeholders](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#placeholders) + - [Custom Placeholders](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#custom-placeholders) + ## [Released - 0.0.9] - 2021-09-20 - #### Fixed Bugs Snippets. diff --git a/README.md b/README.md index a0a6050..857a2f3 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,15 @@ ext install adereksisusanto.codeigniter4-snippets ### Table of Content - [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md) + - [Controller Resources](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md#controller-resources) Update + - [Controller Presenter](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md##controller-presenter) New - [Migrations](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/MIGRATIONS.md) - [Models](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/MODELS.md) -- [Routes](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md) -- [Validation](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/VALIDATIONS.md) [new] - - [Validation in Controller](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/VALIDATIONS.md#validation-in-controller) [new] +- [Routes](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md) New + - [Placeholders](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#placeholders) New + - [Custom Placeholders](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#custom-placeholders) New +- [Validation](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/VALIDATIONS.md) + - [Validation in Controller](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/VALIDATIONS.md#validation-in-controller) - [Views](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/Views.md) Happy coding! diff --git a/docs/CONTROLLERS.md b/docs/CONTROLLERS.md index 14deb03..ce15058 100644 --- a/docs/CONTROLLERS.md +++ b/docs/CONTROLLERS.md @@ -3,63 +3,173 @@ ### `[ProjectRoot]/app/Controllers/*.php` ### Table of Content - -- [Alternate Snippets for Controllers](#alternate-snippets-for-controllers) -- [`[ProjectRoot]/app/Controllers/*.php`](#projectrootappcontrollersphp) -- [Table of Content](#table-of-content) - [Controllers](#controllers) - - [Controller Resources](#controller-resources) + - [Controller Resources](#controller-resources) Update + - [Controller Presenter](#controller-presenter) New #### Controllers -- Command - ```code - ci4:controller - ``` -- Output - ```php - public function index() - { - // code - } - ``` - -#### Controller Resources - -- Command - ```code - ci4:controller:resources - ``` -- Output - - ```php - public function __construct() - { - // __construct code - } - - public function index() - { - // index code - } - - public function create() - { - // create code - } - - public function read($id) - { - // read code - } - - public function update($id) - { - // update code - } - - public function delete($id) - { - // delete code - } - ``` \ No newline at end of file + + + + + + + + + + + + + +
COMMANDSRENDERS
+ +```code +ci4:controller +``` + + +```php +public function index() +{ + // code +} +``` +
+ +##### Controller Resources + + + + + + + + + + + + + + +
COMMANDSRENDERS
+ +```code +ci4:controller:resources +``` + + + +```php +public function __construct() +{ + // __construct code +} + +public function index() +{ + // index code +} + +public function show($id = null) +{ + // show code +} + +public function new() +{ + // new code +} + +public function create() +{ + // create code +} + +public function edit($id = null) +{ + // edit code +} + +public function update($id = null) +{ + // update code +} + +public function delete($id = null) +{ + // delete code +} +``` +
+ +##### Controller Presenter + + + + + + + + + + + + + + +
COMMANDSRENDERS
+ +```code +ci4:controller:presenter +``` + + + +```php +public function __construct() +{ + // __construct code +} + +public function index() +{ + // index code +} + +public function show($id = null) +{ + // show code +} + +public function new() +{ + // new code +} + +public function create() +{ + // create code +} + +public function edit($id = null) +{ + // edit code +} + +public function update($id = null) +{ + // update code +} + +public function remove($id = null) +{ + // remove code +} + +public function delete($id = null) +{ + // delete code +} +``` +
\ No newline at end of file diff --git a/docs/ROUTES.md b/docs/ROUTES.md index 7d100ba..8ad0ed9 100644 --- a/docs/ROUTES.md +++ b/docs/ROUTES.md @@ -2,43 +2,64 @@ ### `[ProjectRoot]/app/Config/Routes.php` - +### Table of Content + +- [Routes](#routes) New + - [Placeholders](#placeholders) New + - [Custom Placeholders](#custom-placeholders) New + +### Routes +
- - - + + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + + + +
CommandDescriptionOutputCOMMANDSRESULTS
ci4:routes:addMake Routes add() + + +```code +ci4:routes:add +``` + + ```php $routes->add('url', 'ControllerName::index'); ``` -
ci4:routes:cliMake Command-Line only Routes + + +```code +ci4:routes:cli +``` + + ```php $routes->cli('migrate', 'App\Database::migrate'); ``` -
ci4:routes:envMake Routes Environment + + +```code +ci4:routes:env +``` + + ```php $routes->environment('development' , function($routes) @@ -46,26 +67,34 @@ $routes->environment('development' , function($routes) $routes->add('builder','Tools\Builder::index'); }); ``` -
ci4:routes:getMake Routes get() + + +```code +ci4:routes:get +``` + + ```php $routes->get('url', 'ControllerName::index'); ``` -
ci4:routes:groupMake Routes group() + + +```code +ci4:routes:group +``` + + ```php $routes->group('admin', function($routes) @@ -73,14 +102,18 @@ $routes->group('admin', function($routes) $routes->add('url', 'ControllerName::index'); }); ``` -
ci4:routes:group-filterMake Routes group() filter + + +```code +ci4:routes:group-filter +``` + + ```php $routes->group('api' , ['filter' => 'api-auth'], function($routes) @@ -88,14 +121,18 @@ $routes->group('api' , ['filter' => 'api-auth'], function($routes) $routes->resource('url'); }); ``` -
ci4:routes:group-multipleMake Routes group() multiple + + +```code +ci4:routes:group-multiple +``` + + ```php $routes->group('admin', function($routes) @@ -106,14 +143,18 @@ $routes->group('admin', function($routes) }); }); ``` -
ci4:routes:group-namespaceMake Routes group() namespace + + +```code +ci4:routes:group-namespace +``` + + ```php $routes->group('api' , ['namespace' => 'App\API\v1'], function($routes) @@ -121,31 +162,100 @@ $routes->group('api' , ['namespace' => 'App\API\v1'], function($routes) //Route }); ``` -
ci4:routes:postMake Routes post() + + +```code +ci4:routes:post +``` + + ```php $routes->post('url', 'ControllerName::index'); ``` -
ci4:routes:subdomainMake Routes Limit to Subdomains + + +```code +ci4:routes:subdomain +``` + + ```php $routes->add('from', 'to', ['subdomain' => '*']); ``` +
+ +#### Placeholders + + + + + + + + + + + + + +
COMMANDSRESULTS
+ +```code +ci4:routes:placeholder +``` + + + +```php +$routes->type('url/(:placeholder)', 'ControllerName::index/$1'); +``` + +Type : add, get, post, put, delete
+Placeholder : any, segment, num, alpha, alphanum, hash
+
+
+#### Custom Placeholders + + + + + + + + + + + diff --git a/package.json b/package.json index ddfe2e9..17dcfe4 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "CodeIgniter4 Snippets for Visual Studio Code", "icon": "ci4.png", "publisher": "adereksisusanto", - "version": "0.0.9", + "version": "0.1.0", "engines": { "vscode": "^1.53.0" }, @@ -28,7 +28,7 @@ }, { "language": "php", - "path": "./snippets/php_controllers.json" + "path": "./snippets/php_models.json" }, { "language": "php", diff --git a/snippets/php_controllers.json b/snippets/php_controllers.json index 61e919e..46906f6 100644 --- a/snippets/php_controllers.json +++ b/snippets/php_controllers.json @@ -24,26 +24,87 @@ "\t\\index code", "}", "", + "public function show(\\$id = null)", + "{", + "\t\\show code", + "}", + "", + "public function new()", + "{", + "\t\\new code", + "}", + "", "public function create()", "{", "\t\\create code", "}", "", - "public function read(\\$id)", + "public function edit(\\$id = null)", "{", - "\t\\read code", + "\t\\edit code", "}", "", - "public function update(\\$id)", + "public function update(\\$id = null)", "{", "\t\\update code", "}", "", - "public function delete(\\$id)", + "public function delete(\\$id = null)", "{", "\t\\delete code", "}$0" ], "description": "CodeIgniter 4 - Make Controler Resources" + }, + "Codeigniter4_Controller_Presenter": { + "prefix": "ci4:controller:presenter", + "lang": ["php"], + "body": [ + "public function __construct()", + "{", + "\t\\__construct code", + "}", + "", + "public function index()", + "{", + "\t\\index code", + "}", + "", + "public function show(\\$id = null)", + "{", + "\t\\show code", + "}", + "", + "public function new()", + "{", + "\t\\new code", + "}", + "", + "public function create()", + "{", + "\t\\create code", + "}", + "", + "public function edit(\\$id = null)", + "{", + "\t\\edit code", + "}", + "", + "public function update(\\$id = null)", + "{", + "\t\\update code", + "}", + "", + "public function remove(\\$id = null)", + "{", + "\t\\remove code", + "}", + "", + "public function delete(\\$id = null)", + "{", + "\t\\delete code", + "}$0" + ], + "description": "CodeIgniter 4 - Make Controler Presenter" } } \ No newline at end of file diff --git a/snippets/php_routes.json b/snippets/php_routes.json index bc4a312..47beb08 100644 --- a/snippets/php_routes.json +++ b/snippets/php_routes.json @@ -36,7 +36,7 @@ "body": [ "\\$routes->group('${1:admin}', function(\\$routes)", "{", - "\t\\$routes->add('${2:url}','${3:ControllerName}::${4:index}')", + "\t\\$routes->add('${2:url}','${3:ControllerName}::${4:index};')", "});$0" ], "description": "CodeIgniter 4 - Make Routes group()" @@ -60,7 +60,7 @@ "{", "\t\\$routes->group('${2:users}', function(\\$routes)", "\t{", - "\t\t\\${3://Route}", + "\t\t\\${3:// Route}", "\t});", "});$0" ], @@ -77,6 +77,23 @@ ], "description": "CodeIgniter 4 - Make Routes group() namespace" }, + "Codeigniter4_ROUTES_PLACEHOLDER": { + "prefix": "ci4:routes:placeholder", + "lang": ["php"], + "body": [ + "\\$routes->${1|add,get,post,put,delete|}('${2:url}/(:${3|any,segment,num,alpha,alphanum,hash|})','${4:ControllerName}::${5:index}/\\$1');$0" + ], + "description": "CodeIgniter 4 - Make Routes Placeholder (:any) (:segment) (:num) (:alpha) (:alphanum) (:hash)" + }, + "Codeigniter4_ROUTES_PLACEHOLDER_CUSTOM": { + "prefix": "ci4:routes:placeholder:custom", + "lang": ["php"], + "body": [ + "\\$routes->addPlaceholder('${1:uuid}', '${2:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}');", + "\\$routes->${3|add,get,post,put,delete|}('${4:url}/(:${1:uuid})','${5:ControllerName}::${6:index}/\\$1');$0" + ], + "description": "CodeIgniter 4 - Make Routes Custom Placeholder default (:uuid)" + }, "Codeigniter4_ROUTES_POST": { "prefix": "ci4:routes:post", "lang": ["php"],
COMMANDSRESULTS
+ +```code +ci4:routes:placeholder:custom +``` + + + +```php +$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'); +$routes->type('url/(:uuid)', 'ControllerName::index/$1'); +``` + +Type : add, get, post, put, delete
+