update cmd line

This commit is contained in:
asep komarudin 2023-03-03 07:09:50 +07:00
parent 67a507d530
commit 8c55f6b749
214 changed files with 48553 additions and 48489 deletions

View file

@ -0,0 +1 @@
custom: ['https://codeigniter.com']

3
snippets/codeigniter4/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.vsix
*.NOTE.md
*.ex.json

View file

@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}

View file

@ -0,0 +1,7 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
docs/**
*.ex.json
*.NOTE.md

View file

@ -0,0 +1,163 @@
# Change Log
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.1.1) 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.1] - 2021-10-18
- #### Fixed Bugs Snippets.
- #### Add New Snippets.
- [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md)
- [Request Class](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md#controller-request-class)
- [Routes](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md)
- [Presenter](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#presenter)
- [Resource](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#resource)
## [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.
- #### Add New Snippets.
- ##### [Validations](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)
## [Released - 0.0.8] - 2021-04-18
- #### Add New Snippets.
- ##### [Migrations](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/MIGRATIONS.md)
## [Released - 0.0.7] - 2021-04-06
- #### Add New Snippets.
- ##### [Migrations](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/MIGRATIONS.md)
## [Released - 0.0.6] - 2021-04-05
- #### Fixed Bugs Snippets.
- #### Add New Snippets.
- ##### [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md)
- ##### [Models](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/MODELS.md)
## [Released - 0.0.5]
- #### Fixed Bugs Links.
## [Released - 0.0.4]
- #### Fixed Bugs.
- #### Change Command ( [read](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CHANGE.md) ).
- #### Add Docs.
- ##### [Routes](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md)
- ##### [Views](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/VIEWS.md)
- #### Add New Snippets {`[ProjectRoot]/app/Views/**.php`}
<table>
<thead>
<tr>
<th align="center">Command</th>
<th align="center">Description</th>
<th align="center">Output</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap>ci4:views:foreach</td>
<td>Make <code>foreach</code> in View files</td>
<td>
```php
<?php foreach ($items as $item) : ?>
<li><?= $item ?></li>
<?php endforeach ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if</td>
<td>Make <code>if</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-else</td>
<td>Make <code>if else</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php else : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-elseif</td>
<td>Make <code>if elseif</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php elseif (condition) : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-elseif-else</td>
<td>Make <code>if elseif else</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE 1 -->
<?php elseif (condition) : ?>
<!-- TRUE 2 -->
<?php else : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
</tbody>
</table>
## License & Download
[![GitHub license](https://img.shields.io/github/license/adereksisusanto/codeigniter4-snippets.svg)](https://github.com/adereksisusanto/codeigniter4-snippets) ![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/adereksisusanto.codeigniter4-snippets)

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 adereksisusanto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,45 @@
# Codeigniter 4 Snippets for Vscode
This Extensions provides the Codeigniter 4 snippets
## Requirements
```bash
CodeIgniter Version : 4.1.4
```
## Install
Launch Code's command palette
```bash
ext install adereksisusanto.codeigniter4-snippets
```
### Table of Content
- [Controllers](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md)
- [Presenter](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md##controller-presenter)
- [Resources](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md#controller-resources)
- [Request Class](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/CONTROLLERS.md#controller-request-class) <sup style="color:red">New</sup>
- [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)
- [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)
- [Presenter](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#presenter) <sup style="color:red">New</sup>
- [Resource](https://github.com/adereksisusanto/codeigniter4-snippets/blob/main/docs/ROUTES.md#resource) <sup style="color:red">New</sup>
- [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!
## 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)
## License & Download
[![GitHub license](https://img.shields.io/github/license/adereksisusanto/codeigniter4-snippets.svg)](https://github.com/adereksisusanto/codeigniter4-snippets) ![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/adereksisusanto.codeigniter4-snippets)

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -0,0 +1,298 @@
## Change Command Snippets
---
### Alternate Snippets for View Files
### `[ProjectRoot]/app/Views/**.php`
<table>
<thead>
<tr>
<th align="center" colspan="2">Command</th>
<th align="center" rowspan="2">Description</th>
<th align="center" rowspan="2">Output</th>
</tr>
<tr>
<th align="center">Lates</th>
<th align="center">News</th>
</tr>
</thead>
<tbody>
<tr>
<td>ci4_endsection</td>
<td nowrap>ci4:views:endSection</td>
<td>Make end Section </td>
<td>
```php
<?= $this->endSection() ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_extend</td>
<td nowrap>ci4:views:extend</td>
<td>Using Layouts in Views</td>
<td>
```php
<?= $this->extend('layouts') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_include</td>
<td nowrap>ci4:views:include</td>
<td>Including View Partials</td>
<td>
```php
<?= $this->include('sidebar') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_php</td>
<td nowrap>ci4:views:php</td>
<td>Make php tag</td>
<td>
```php
<?php code ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_php_echo</td>
<td nowrap>ci4:views:php-echo</td>
<td>Make php echo tag</td>
<td>
```php
<?= code ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_rendersection</td>
<td nowrap>ci4:views:renderSection</td>
<td>Make render Section</td>
<td>
```php
<?= $this->renderSection('content') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_section</td>
<td nowrap>ci4:views:section</td>
<td>Make Section</td>
<td>
```php
<?= $this->section('content') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_sectionend</td>
<td nowrap>ci4:views:section-endSection</td>
<td>Make Section with end Section</td>
<td>
```php
<?= $this->section('content') ;?>
<!-- CODE HERE -->
<?= $this->endSection() ;?>
```
</td>
</tr>
</tbody>
</table>
---
### Alternate Snippets for Routes
### `[ProjectRoot]/app/Config/Routes.php`
<table>
<thead>
<tr>
<th align="center" colspan="2">Command</th>
<th align="center" rowspan="2">Description</th>
<th align="center" rowspan="2">Output</th>
</tr>
<tr>
<th align="center">Lates</th>
<th align="center">News</th>
</tr>
</thead>
<tbody>
<tr>
<td>ci4_routes_add</td>
<td nowrap>ci4:routes:add</td>
<td>Make Routes add() </td>
<td>
```php
$routes->add('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_cli</td>
<td nowrap>ci4:routes:cli</td>
<td>Make Command-Line only Routes</td>
<td>
```php
$routes->cli('migrate', 'App\Database::migrate');
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_env</td>
<td nowrap>ci4:routes:env</td>
<td>Make Routes Environment</td>
<td>
```php
$routes->environment('development' , function($routes)
{
$routes->add('builder','Tools\Builder::index');
});
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_get</td>
<td nowrap>ci4:routes:get</td>
<td>Make Routes get()</td>
<td>
```php
$routes->get('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_group</td>
<td nowrap>ci4:routes:group</td>
<td>Make Routes group()</td>
<td>
```php
$routes->group('admin', function($routes)
{
//Route
});
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_group_filter</td>
<td nowrap>ci4:routes:group-filter</td>
<td>Make Routes group() filter</td>
<td>
```php
$routes->group('api' , ['filter' => 'api-auth'], function($routes)
{
$routes->resource('url');
});
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_group_multiple</td>
<td nowrap>ci4:routes:group-multiple</td>
<td>Make Routes group() multiple</td>
<td>
```php
$routes->group('admin', function($routes)
{
$routes->group('users', function($routes)
{
//Route
});
});
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_group_namespace</td>
<td nowrap>ci4:routes:group-namespace</td>
<td>Make Routes group() namespace</td>
<td>
```php
$routes->group('api' , ['namespace' => 'App\API\v1'], function($routes)
{
//Route
});
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_post</td>
<td nowrap>ci4:routes:post</td>
<td>Make Routes post()</td>
<td>
```php
$routes->post('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td>ci4_routes_subdomain</td>
<td nowrap>ci4:routes:subdomain</td>
<td>Make Routes Limit to Subdomains</td>
<td>
```php
$routes->add('from', 'to', ['subdomain' => '*']);
```
</td>
</tr>
<!-- -->
</tbody>
</table>

View file

@ -0,0 +1,208 @@
### Alternate Snippets for Controllers
### `[ProjectRoot]/app/Controllers/**.php`
### Table of Content
- [Controllers](#controllers)
- [Presenter](#presenter)
- [Resources](#resources)
- [Request Class](#request-class) <sup style="color:red">New</sup>
#### Controllers
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RENDERS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:controller
```
</td>
<td nowrap>
```php
public function index()
{
// code
}
```
</td>
</tr>
</tbody>
</table>
##### Presenter
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RENDERS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:controller:presenter
```
</td>
<td nowrap>
```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
}
```
</td>
</tr>
</tbody>
</table>
##### Resources
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RENDERS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:controller:resources
```
</td>
<td nowrap>
```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
}
```
</td>
</tr>
</tbody>
</table>
##### Request Class
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RENDERS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:controller:request
```
</td>
<td nowrap>
```php
$this->request->Type('field name');
```
<small>
<strong>Type : </strong>getVar, getGet, getPost, getMethod, isAjax, isCLI, isSecure<br>
</small>
</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,245 @@
# Alternate Snippets for Migrations
## `[ProjectRoot]/app/Database/Migrations/`
# Table of Content
- [Create Migration](#create-migration)
- [Migration Up](#migration-up)
- [Migration Down](#migration-down)
- [Create Table](#create-table)
- [Add Column](#add-column) [new]
- [BIGINT](#bigint) [new]
- [CHAR](#char) [new]
- [DATETIME](#datetime) [new]
- [INT](#int) [new]
- [VARCHAR](#varchar) [new]
- [ID](#id) [new]
- [Timestamp](#timestamp)
## Create Migration
**Command**
```bash
ci4:migration
```
**Output**
```php
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddBlog extends Migration
{
public function up()
{
//
}
public function down()
{
//
}
}
```
- ### Migration Up
**Command**
```bash
ci4:migration:up
```
**Output**
```php
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
'deleted_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('tableName');
}
```
- ### Migration Down
**Command**
```bash
ci4:migration:down
```
**Output**
```php
public function down()
{
$this->forge->dropTable('tableName');
}
```
## Create Table
- ### Add Column
- #### BIGINT
**Command**
```bash
ci4:migration:bigint
```
**Output**
```php
'columnName' => [
'type' => 'BIGINT',
'constraint' => '20',
'null' => true,
],
```
- #### CHAR
**Command**
```bash
ci4:migration:char
```
**Output**
```php
'columnName' => [
'type' => 'CHAR',
'constraint' => '10',
'null' => true,
],
```
- #### DATETIME
**Command**
```bash
ci4:migration:datetime
```
**Output**
```php
'columnName' => [
'type' => 'DATETIME',
'null' => true,
],
```
- #### INT
**Command**
```bash
ci4:migration:int
```
**Output**
```php
'columnName' => [
'type' => 'INT',
'constraint' => '11',
'null' => true,
],
```
- #### VARCHAR
**Command**
```bash
ci4:migration:varchar
```
**Output**
```php
'columnName' => [
'type' => 'VARCHAR',
'constraint' => '255',
'null' => true,
],
```
- ### ID
**Command :**
```bash
ci4:migration:id
```
**Output :**
```php
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
```
- ### Timestamp
**Command :**
```bash
ci4:migration:timestamp
```
**Output :**
```php
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
'deleted_at' => [
'type' => 'DATETIME',
'null' => true,
],
```

View file

@ -0,0 +1,36 @@
### Alternate Snippets for Models
### `[ProjectRoot]/app/Models/*.php`
### Table of Content
- [Model Config](#model-config) [new]
#### Model Config
- Command
```bash
ci4:model:config
```
- Output
```php
protected $table = 'tableName';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = true;
protected $allowedFields = ['name'];
protected $useTimestamps = false;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
```

View file

@ -0,0 +1,319 @@
### Alternate Snippets for Routes
### `[ProjectRoot]/app/Config/Routes.php`
### Table of Content
<!-- - [Alternate Snippets for Routes](#alternate-snippets-for-routes)
- [`[ProjectRoot]/app/Config/Routes.php`](#projectrootappconfigroutesphp)
- [Table of Content](#table-of-content) -->
- [Routes](#routes)
- [Placeholders](#placeholders)
- [Custom Placeholders](#custom-placeholders)
- [Presenter](#presenter)
- [Resource](#resource)
### Routes
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RESULTS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:add
```
</td>
<td nowrap>
```php
$routes->add('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:cli
```
</td>
<td nowrap>
```php
$routes->cli('migrate', 'App\Database::migrate');
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:env
```
</td>
<td nowrap>
```php
$routes->environment('development' , function($routes)
{
$routes->add('builder','Tools\Builder::index');
});
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:get
```
</td>
<td nowrap>
```php
$routes->get('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:group
```
</td>
<td nowrap>
```php
$routes->group('admin', function($routes)
{
$routes->add('url', 'ControllerName::index');
});
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:group-filter
```
</td>
<td nowrap>
```php
$routes->group('api' , ['filter' => 'api-auth'], function($routes)
{
$routes->resource('url');
});
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:group-multiple
```
</td>
<td nowrap>
```php
$routes->group('admin', function($routes)
{
$routes->group('users', function($routes)
{
//Route
});
});
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:group-namespace
```
</td>
<td nowrap>
```php
$routes->group('api' , ['namespace' => 'App\API\v1'], function($routes)
{
//Route
});
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:post
```
</td>
<td nowrap>
```php
$routes->post('url', 'ControllerName::index');
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:subdomain
```
</td>
<td nowrap>
```php
$routes->add('from', 'to', ['subdomain' => '*']);
```
</td>
</tr>
</tbody>
</table>
#### Placeholders
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RESULTS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:placeholder
```
</td>
<td nowrap>
```php
$routes->type('url/(:placeholder)', 'ControllerName::index/$1');
```
<small>
<strong>Type : </strong>add, get, post, put, delete<br>
<strong>Placeholder : </strong>any, segment, num, alpha, alphanum, hash<br>
</small>
</td>
</tr>
</tbody>
</table>
#### Custom Placeholders
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RESULTS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:placeholder:custom
```
</td>
<td nowrap>
```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');
```
<small>
<strong>Type : </strong>add, get, post, put, delete<br>
</small>
</td>
</tr>
<!-- -->
</tbody>
</table>
#### Presenter
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RESULTS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:presenter
```
</td>
<td nowrap>
```php
$routes->presenter('url');
```
</td>
</tr>
</tbody>
</table>
#### Resource
<table style="width:100%">
<thead>
<tr>
<th align="center">COMMANDS</th>
<th align="center">RESULTS</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap style="vertical-align: top;">
```code
ci4:routes:resource
```
</td>
<td nowrap>
```php
$routes->resource('url');
```
</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,34 @@
### Alternate Snippets for Validation
### Table of Content
- [Alternate Snippets for Validation](#alternate-snippets-for-validation)
- [Table of Content](#table-of-content)
- [Validation](#validation)
- [Validation in Controller](#validation-in-controller)
### Validation
#### Validation in Controller
- Command
```code
ci4:validation:controller
```
- Output
```php
$validation = \Config\Services::validation();
$rules = [
'field_1' => [
'label' => 'Field 1 Custom Name',
'rules' => 'required',
'errors' => [
'required' => '{field} is required.'
]
],
];
if (!$this->validate($rules)) {
return redirect()->to('/route')->withInput()->with('validation', $validation);
}
```

View file

@ -0,0 +1,190 @@
### Alternate Snippets for View Files
### `[ProjectRoot]/app/Views/**.php`
<table>
<thead>
<tr>
<th align="center">Command</th>
<th align="center">Description</th>
<th align="center">Output</th>
</tr>
</thead>
<tbody>
<tr>
<td nowrap>ci4:views:endSection</td>
<td>Make end Section in View files</td>
<td>
```php
<?= $this->endSection() ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:extend</td>
<td>Using Layouts in Views</td>
<td>
```php
<?= $this->extend('layouts') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:foreach</td>
<td>Make <code>foreach</code> in View files</td>
<td>
```php
<?php foreach ($items as $item) : ?>
<li><?= $item ?></li>
<?php endforeach ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if</td>
<td>Make <code>if</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-else</td>
<td>Make <code>if else</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php else : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-elseif</td>
<td>Make <code>if elseif</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE -->
<?php elseif (condition) : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:if-elseif-else</td>
<td>Make <code>if elseif else</code> in View files</td>
<td>
```php
<?php if (condition) : ?>
<!-- TRUE 1 -->
<?php elseif (condition) : ?>
<!-- TRUE 2 -->
<?php else : ?>
<!-- FALSE -->
<?php endif ?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:include</td>
<td>Including View Partials</td>
<td>
```php
<?= $this->include('sidebar') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:php</td>
<td>Make php tag in View files</td>
<td>
```php
<?php code ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:php-echo</td>
<td>Make php echo tag in View files</td>
<td>
```php
<?= code ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:renderSection</td>
<td>Make render Section in View files</td>
<td>
```php
<?= $this->renderSection('content') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:section</td>
<td>Make Section in View files</td>
<td>
```php
<?= $this->section('content') ;?>
```
</td>
</tr>
<!-- -->
<tr>
<td nowrap>ci4:views:section-endSection</td>
<td>Make Section with end Section in View files</td>
<td>
```php
<?= $this->section('content') ;?>
<!-- CODE HERE -->
<?= $this->endSection() ;?>
```
</td>
</tr>
</tbody>
</table>

View file

@ -0,0 +1,51 @@
{
"name": "codeigniter4-snippets",
"displayName": "CodeIgniter4 Snippets",
"description": "CodeIgniter4 Snippets for Visual Studio Code",
"icon": "ci4.png",
"publisher": "adereksisusanto",
"version": "0.1.1",
"engines": {
"vscode": "^1.53.0"
},
"keywords": [
"codeigniter4",
"snippets",
"php",
"html"
],
"repository": {
"type": "git",
"url": "https://github.com/adereksisusanto/codeigniter4-snippets"
},
"categories": [
"Snippets"
],
"contributes": {
"snippets": [{
"language": "php",
"path": "./snippets/php_controllers.json"
},
{
"language": "php",
"path": "./snippets/php_models.json"
},
{
"language": "php",
"path": "./snippets/php_migrations.json"
},
{
"language": "php",
"path": "./snippets/php_routes.json"
},
{
"language": "php",
"path": "./snippets/php_validations.json"
},
{
"language": "html",
"path": "./snippets/html_views.json"
}
]
}
}

View file

@ -0,0 +1,113 @@
{
"Codeigniter4_VIEWS_ENDSECTION": {
"prefix": "ci4:views:endSection",
"lang": ["html"],
"body": ["<?= \\$this->endSection() ;?>$0"],
"description": "CodeIgniter 4 - Make end Section in View files"
},
"Codeigniter4_VIEWS_EXTEND": {
"prefix": "ci4:views:extend",
"lang": ["html"],
"body": ["<?= \\$this->extend('${1:layouts}') ;?>$0"],
"description": "CodeIgniter 4 - Using Layouts in Views"
},
"Codeigniter4_VIEWS_FOREACH": {
"prefix": "ci4:views:foreach",
"lang": ["html"],
"body": [
"<?php foreach (${1:\\$items} as ${2:\\$item}) : ?>",
"\t<${3:li}><?= ${4:\\$item}['${5:id}'] ?></${3:li}>",
"<?php endforeach ?>$0"
],
"description": "CodeIgniter 4 - Make foreach in View files"
},
"Codeigniter4_VIEWS_IF": {
"prefix": "ci4:views:if",
"lang": ["html"],
"body": [
"<?php if (${1:condition}) : ?>",
"\t${2:<!-- TRUE -->}",
"<?php endif ?>$0"
],
"description": "CodeIgniter 4 - Make if in View files"
},
"Codeigniter4_VIEWS_IF_ELSE": {
"prefix": "ci4:views:if-else",
"lang": ["html"],
"body": [
"<?php if (${1:condition}) : ?>",
"\t${2:<!-- TRUE -->}",
"<?php else : ?>",
"\t${3:<!-- FALSE -->}",
"<?php endif ?>$0"
],
"description": "CodeIgniter 4 - Make if else in View files"
},
"Codeigniter4_VIEWS_IF_ELSEIF": {
"prefix": "ci4:views:if-elseif",
"lang": ["html"],
"body": [
"<?php if(${1:condition}) : ?>",
"\t${2:<!-- TRUE -->}",
"<?php elseif (${3:condition}) : ?>",
"\t${4:<!-- FALSE -->}",
"<?php endif ?>$0"
],
"description": "CodeIgniter 4 - Make if elseif in View files"
},
"Codeigniter4_VIEWS_IF_ELSEIF_ELSE": {
"prefix": "ci4:views:if-elseif-else",
"lang": ["html"],
"body": [
"<?php if(${1:condition}) : ?>",
"\t${2:<!-- TRUE 1 -->}",
"<?php elseif (${3:condition}) : ?>",
"\t${4:<!-- TRUE 2 -->}",
"<?php else : ?>",
"\t${5:<!-- FALSE -->}",
"<?php endif ?>$0"
],
"description": "CodeIgniter 4 - make if elseif else in View files"
},
"Codeigniter4_VIEWS_INCLUDE": {
"prefix": "ci4:views:include",
"lang": ["html"],
"body": ["<?= \\$this->include('${1:sidebar}') ;?>$0"],
"description": "CodeIgniter 4 - Including View Partials"
},
"Codeigniter4_VIEWS_PHP": {
"prefix": "ci4:views:php",
"lang": ["html"],
"body": ["<?php ${1:code} ;?>$0"],
"description": "CodeIgniter 4 - Make php tag in View files"
},
"Codeigniter4_VIEWS_PHP_ECHO": {
"prefix": "ci4:views:php-echo",
"lang": ["html"],
"body": ["<?= ${1:code} ;?>$0"],
"description": "CodeIgniter 4 - Make php echo tag in View files"
},
"Codeigniter4_VIEWS_RENDERSECTION": {
"prefix": "ci4:views:renderSection",
"lang": ["html"],
"body": ["<?= \\$this->renderSection('${1:content}') ;?>$0"],
"description": "CodeIgniter 4 - Make render Section in View files"
},
"Codeigniter4_VIEWS_SECTION": {
"prefix": "ci4:views:section",
"lang": ["html"],
"body": ["<?= \\$this->section('${1:content}') ;?>$0"],
"description": "CodeIgniter 4 - Make Section in View files"
},
"Codeigniter4_VIEWS_SECTION_ENDSECTION": {
"prefix": "ci4:views:section-endSection",
"lang": ["html"],
"body": [
"<?= \\$this->section('${1:content}') ;?>",
"${2:<!-- CODE HERE -->}",
"<?= \\$this->endSection() ;?>",
"$0"
],
"description": "CodeIgniter 4 - Make Section with end Section in View files"
}
}

View file

@ -0,0 +1,118 @@
{
"Codeigniter4_Controller": {
"prefix": "ci4:controller",
"lang": ["php"],
"body": [
"public function ${1:index}(${2:\\$request})",
"{",
"\t\\\\${3:code}",
"}$0"
],
"description": "CodeIgniter 4 - Make Controller"
},
"Codeigniter4_Controller_Resources": {
"prefix": "ci4:controller:resources",
"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 delete(\\$id = null)",
"{",
"\t\\\\delete code",
"}$0"
],
"description": "CodeIgniter 4 - Make Controller 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"
},
"Codeigniter4_Controller_Request": {
"prefix": "ci4:controller:request",
"lang": ["php"],
"body": [
"\\$this->request->${1|getVar,getGet,getPost,getMethod,isAjax,isCLI,isSecure|}('${2:field name}');$0"
],
"description": "CodeIgniter 4 - Make Controller Request Class"
}
}

View file

@ -0,0 +1,165 @@
{
"Codeigniter4_Migration": {
"prefix": "ci4:migration",
"lang": ["php"],
"body": [
"<?php",
"",
"namespace App\\\\Database\\\\Migrations;",
"",
"use CodeIgniter\\\\Database\\\\Migration;",
"",
"class ${1:AddBlog} extends Migration",
"{",
"\tpublic function up()",
"\t{",
"\t\t$2",
"\t}",
"",
"\tpublic function down()",
"\t{",
"\t\t$3",
"\t}",
"}$0"
],
"description": "CodeIgniter 4 - Make Migration"
},
"Codeigniter4_Migration_Up": {
"prefix": "ci4:migration:up",
"lang": ["php"],
"body": [
"public function up()",
"{",
"\t\\$this->forge->addField([",
"\t\t'${1:id}' => [",
"\t\t\t'type' => 'INT',",
"\t\t\t'constraint' => 11,",
"\t\t\t'unsigned' => true,",
"\t\t\t'auto_increment' => true,",
"\t\t],",
"\t\t'${2:name}' => [",
"\t\t\t'type' => 'VARCHAR',",
"\t\t\t'constraint' => 255,",
"\t\t],",
"\t\t'created_at' => [",
"\t\t\t'type' => 'DATETIME',",
"\t\t\t'null' => true,",
"\t\t],",
"\t\t'updated_at' => [",
"\t\t\t'type' => 'DATETIME',",
"\t\t\t'null' => true,",
"\t\t],",
"\t\t'deleted_at' => [",
"\t\t\t'type' => 'DATETIME',",
"\t\t\t'null' => true,",
"\t\t],",
"\t]);",
"\t\\$this->forge->addKey('${1:id}', true);",
"\t\\$this->forge->createTable('${3:tableName}');",
"}$0"
],
"description": "CodeIgniter 4 - Make Migration Up"
},
"Codeigniter4_Migration_Down": {
"prefix": "ci4:migration:down",
"lang": ["php"],
"body": [
"public function down()",
"{",
"\t\\$this->forge->dropTable('${1:tableName}');",
"}$0"
],
"description": "CodeIgniter 4 - Make Migration Down"
},
"Codeigniter4_Migration_BIGINT": {
"prefix": "ci4:migration:bigint",
"lang": ["php"],
"body": [
"'${1:columnName}' => [",
"\t'type' => 'BIGINT',",
"\t'constraint' => 20,",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Type (BIG INTEGER)"
},
"Codeigniter4_Migration_CHAR": {
"prefix": "ci4:migration:char",
"lang": ["php"],
"body": [
"'${1:columnName}' => [",
"\t'type' => 'CHAR',",
"\t'constraint' => 10,",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Type (CHAR)"
},
"Codeigniter4_Migration_DATETIME": {
"prefix": "ci4:migration:datetime",
"lang": ["php"],
"body": [
"'${1:columnName}' => [",
"\t'type' => 'DATETIME',",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Type (CHAR)"
},
"Codeigniter4_Migration_INT": {
"prefix": "ci4:migration:int",
"lang": ["php"],
"body": [
"'${1:columnName}' => [",
"\t'type' => 'INT',",
"\t'constraint' => 11,",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Type (INTEGER)"
},
"Codeigniter4_Migration_VARCHAR": {
"prefix": "ci4:migration:varchar",
"lang": ["php"],
"body": [
"'${1:columnName}' => [",
"\t'type' => 'VARCHAR',",
"\t'constraint' => 255,",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Type (VARCHAR)"
},
"Codeigniter4_Migration_ID": {
"prefix": "ci4:migration:id",
"lang": ["php"],
"body": [
"'id' => [",
"\t'type' => 'INT',",
"\t'constraint' => 11,",
"\t'unsigned' => true,",
"\t'auto_increment' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration ID"
},
"Codeigniter4_Migration_Timestamp": {
"prefix": "ci4:migration:timestamp",
"lang": ["php"],
"body": [
"'created_at' => [",
"\t'type' => 'DATETIME',",
"\t'null' => true,",
"],",
"'updated_at' => [",
"\t'type' => 'DATETIME',",
"\t'null' => true,",
"],",
"'deleted_at' => [",
"\t'type' => 'DATETIME',",
"\t'null' => true,",
"],$0"
],
"description": "CodeIgniter 4 - Make Migration Timestamp"
}
}

View file

@ -0,0 +1,28 @@
{
"Codeigniter4_Model_Config": {
"prefix": "ci4:model:config",
"lang": ["php"],
"body": [
"protected \\$table = '${1:tableName}';",
"protected \\$primaryKey = '${2:id}';",
"",
"protected \\$useAutoIncrement = ${3:true};",
"",
"protected \\$returnType = '${4:array}';",
"protected \\$useSoftDeletes = ${5:false};",
"",
"protected \\$allowedFields = ['${6:name}'];",
"",
"protected \\$useTimestamps = ${7:true};",
"protected \\$createdField = '${8:created_at}';",
"protected \\$updatedField = '${9:updated_at}';",
"protected \\$useTimestamps = '${10:deleted_at}';",
"",
"protected \\$validationRules = ${11:[]};",
"protected \\$validationMessages = ${12:[]};",
"protected \\$skipValidation = ${13:false};",
"$0"
],
"description": "CodeIgniter 4 - Make Model Configuring"
}
}

View file

@ -0,0 +1,129 @@
{
"Codeigniter4_ROUTES_ADD": {
"prefix": "ci4:routes:add",
"lang": ["php"],
"body": ["\\$routes->add('${1:url}','${2:ControllerName}::${3:index}');$0"],
"description": "CodeIgniter 4 - Make Routes add()"
},
"Codeigniter4_ROUTES_CLI": {
"prefix": "ci4:routes:cli",
"lang": ["php"],
"body": [
"\\$routes->cli('${1:migrate}','${2:App\\\\Database}::${3:migrate}');$0"
],
"description": "CodeIgniter 4 - Make Command-Line only Routes"
},
"Codeigniter4_ROUTES_ENVIRONMENT": {
"prefix": "ci4:routes:env",
"lang": ["php"],
"body": [
"\\$routes->environment('${1:development}', function(\\$routes)",
"{",
"\t\\$routes->add('${2:builder}','${3:Tools\\\\Builder}::${4:index}');",
"});$0"
],
"description": "CodeIgniter 4 - Make Routes Environment"
},
"Codeigniter4_ROUTES_GET": {
"prefix": "ci4:routes:get",
"lang": ["php"],
"body": ["\\$routes->get('${1:url}','${2:ControllerName}::${3:index}');$0"],
"description": "CodeIgniter 4 - Make Routes get()"
},
"Codeigniter4_ROUTES_GROUP": {
"prefix": "ci4:routes:group",
"lang": ["php"],
"body": [
"\\$routes->group('${1:admin}', function(\\$routes)",
"{",
"\t\\$routes->add('${2:url}','${3:ControllerName}::${4:index};')",
"});$0"
],
"description": "CodeIgniter 4 - Make Routes group()"
},
"Codeigniter4_ROUTES_GROUP_FILTER": {
"prefix": "ci4:routes:group-filter",
"lang": ["php"],
"body": [
"\\$routes->group('${1:api}',['filter' => '${2:api-auth}'], function(\\$routes)",
"{",
"\t\\$routes->resource('${3:url}');",
"});$0"
],
"description": "CodeIgniter 4 - Make Routes group() filter"
},
"Codeigniter4_ROUTES_GROUP_MULTIPLE": {
"prefix": "ci4:routes:group-multiple",
"lang": ["php"],
"body": [
"\\$routes->group('${1:admin}', function(\\$routes)",
"{",
"\t\\$routes->group('${2:users}', function(\\$routes)",
"\t{",
"\t\t\\${3:// Route}",
"\t});",
"});$0"
],
"description": "CodeIgniter 4 - Make Routes group() multiple"
},
"Codeigniter4_ROUTES_GROUP_NAMESPACE": {
"prefix": "ci4:routes:group-namespace",
"lang": ["php"],
"body": [
"\\$routes->group('${1:api}',['namespace' => '${2:App\\\\API\\\\v1}'], function(\\$routes)",
"{",
"\t\\${3://Route}",
"});$0"
],
"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"],
"body": [
"\\$routes->post('${1:url}','${2:ControllerName}::${3:index}');$0"
],
"description": "CodeIgniter 4 - Make Routes post()"
},
"Codeigniter4_ROUTES_PRESENTER": {
"prefix": "ci4:routes:presenter",
"lang": ["php"],
"body": [
"\\$routes->presenter('${1:url}');$0"
],
"description": "CodeIgniter 4 - Make Routes presenter()"
},
"Codeigniter4_ROUTES_RESOURCE": {
"prefix": "ci4:routes:resource",
"lang": ["php"],
"body": [
"\\$routes->resource('${1:url}');$0"
],
"description": "CodeIgniter 4 - Make Routes resource()"
},
"Codeigniter4_ROUTES_SUBDOMAIN": {
"prefix": "ci4:routes:subdomain",
"lang": ["php"],
"body": [
"\\$routes->add('${1:from}', '${2:to}', ['subdomain' => '${2:*}']);$0"
],
"description": "CodeIgniter 4 - Make Routes Limit to Subdomains"
}
}

View file

@ -0,0 +1,23 @@
{
"Codeigniter4_Validation_Controller": {
"prefix": "ci4:validation:controller",
"lang": ["php"],
"body": [
"\\$validation = \\\\Config\\\\Services::validation();",
"\\$rules = [",
"\t 'field_1' => [",
"\t\t'label'\t=> 'Field 1 Custom Name',",
"\t\t'rules'\t=> 'required',",
"\t\t'errors'\t=> [",
"\t\t\t'required'\t=> '{field} is required.'",
"\t\t]",
"\t],",
"];",
"if (!\\$this->validate(\\$rules)) {",
"\treturn redirect()->to('${1:route}')->withInput()->with('validation', \\$validation);",
"}",
"$0"
],
"description": "CodeIgniter 4 - Make Validation in Controller"
}
}