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 +
COMMANDS | +RENDERS | +
---|---|
+ +```code +ci4:controller +``` + | ++ +```php +public function index() +{ + // code +} +``` + | +
COMMANDS | +RENDERS | +
---|---|
+ +```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 +} +``` + | +
COMMANDS | +RENDERS | +
---|---|
+ +```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 +} +``` + | +
Command | -Description | -Output | +COMMANDS | +RESULTS |
---|---|---|---|---|
ci4:routes:add | -Make Routes add() | -+ | + +```code +ci4:routes:add +``` + + | +```php $routes->add('url', 'ControllerName::index'); ``` - |
ci4:routes:cli | -Make Command-Line only Routes | -+ | + +```code +ci4:routes:cli +``` + + | +```php $routes->cli('migrate', 'App\Database::migrate'); ``` - |
ci4:routes:env | -Make 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:get | -Make Routes get() | -+ | + +```code +ci4:routes:get +``` + + | +```php $routes->get('url', 'ControllerName::index'); ``` - |
ci4:routes:group | -Make 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-filter | -Make 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-multiple | -Make 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-namespace | -Make 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:post | -Make Routes post() | -+ | + +```code +ci4:routes:post +``` + + | +```php $routes->post('url', 'ControllerName::index'); ``` - |
ci4:routes:subdomain | -Make Routes Limit to Subdomains | -+ | + +```code +ci4:routes:subdomain +``` + + | +```php $routes->add('from', 'to', ['subdomain' => '*']); ``` + | +
COMMANDS | +RESULTS | +
---|---|
+ +```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 + + |
+
COMMANDS | +RESULTS | +
---|---|
+ +```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 + |