{"id":21514735,"url":"https://github.com/andikod/ci-","last_synced_at":"2026-04-29T15:32:44.841Z","repository":{"id":86840937,"uuid":"219744346","full_name":"AndiKod/ci-","owner":"AndiKod","description":"SublimeText Snippets for CodeIgniter4","archived":false,"fork":false,"pushed_at":"2024-12-06T03:04:40.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T02:29:48.148Z","etag":null,"topics":["codeigniter","codeigniter4","snippets","snippets-collection","sublime-text"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndiKod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-05T12:51:52.000Z","updated_at":"2024-12-25T23:47:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"892a4cd8-8628-4769-9dd1-7143e234453c","html_url":"https://github.com/AndiKod/ci-","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiKod%2Fci-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiKod%2Fci-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiKod%2Fci-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndiKod%2Fci-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndiKod","download_url":"https://codeload.github.com/AndiKod/ci-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066190,"owners_count":20392407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeigniter","codeigniter4","snippets","snippets-collection","sublime-text"],"created_at":"2024-11-23T23:52:47.681Z","updated_at":"2026-04-29T15:32:44.786Z","avatar_url":"https://github.com/AndiKod.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg width=\"248\" height=\"142\" src=\"https://raw.githubusercontent.com/AndiKod/ci-/master/SublimeIgniter.png\" alt=\"SublimeCI\"\u003e\n\n\u003cbr\u003e\u003cbr\u003e\n\n\u003ch1\u003eSublimeSnippets for CodeIgniter4\u003c/h1\u003e\n\t\n\u003c/div\u003e\t\n\n\n![CI4](https://img.shields.io/badge/CodeIgniter-4.0.0--rc3-orange)\n![CI4](https://img.shields.io/badge/SublimeText-3-orange)\n\n\n\n\nThat project was started for my own needs, but some real documentation will follow and the rest of the usefull tags.\n\n\n\nInstall\n-------\n\n---\n\n### Sublime Text - Package Control or Clone/Download\n\nWhen i'll add more snippets, the repo will be proposed as a Sublime Package, but until then you can clone or download it and place the folder inside '**SublimeText3\\Packages\\User**' folder.\n\n\n\nci- here we go...\n--------\n\n**Code** | **Renders** | **Tip**\n---|---|---\n `[ci-m]+Tab` | Model | *Have inside the basics for db connection*\n `[ci-c]+Tab` | Controller | *With data loading from the model and view rendering*\n `[ci-l]+Tab` | Layout | *Naked skeleton, to work with the view below*\n `[ci-v]+Tab` | Vue | *Extending the layout above ^^*\n --- | **- Controllers\u0026Routing -** | ---\n --- | **- inside controllers -** | ---\n `[ci-hw]+Tab` | HelloWorld Controller | *The most basic controller, as a starting point.*\n `[ci-pubF]+Tab` | public function | *For the methods within Controllers, and more*\n `[ci-ptcF]+Tab` | protected function | *For the private logic. See Controllers doc.*\n `[ci-tReq]+Tab` | $this-\u003erequest | *...*\n `[ci-tRsp]+Tab` | $this-\u003eresponse | *...*\n `[ci-tLog]+Tab` | $this-\u003elogger | *...*\n `[ci-load-helpers]+Tab` | Load needed helpers | *Better to load them once in a BaseController*\n `[ci-new-Model]+Tab` | Create the instance... | *Can be done if we first `ci-use-Model`*\n `[ci-get-Model]+Tab` | ...grab the Data. | *Create the array with the data for the 'loop'*\n `[ci-isFile-thEx]+Tab` | Check if file exist | *If not, throw exception. Done before load views.*\n `[ci-data]+Tab` | Creates the $data array | *The strings and arrays to be sent into the Views*\n `[ci-load-Parser]+Tab` | Makes the Parser available | *Captain Obvious striked again.*\n `[ci-load-PView]+Tab` | Renders a 'parsed' View | *Where we echo variables as {title}*\n `[ci-echo-View]+Tab` | Renders a PHP View | *Where we echo variables as `\u003c?= $title ?\u003e`*\n --- | **- filters -** | ---\n `[ci-filter]+Tab` | Filter file skeleton | *For adding filter 'before' and|or 'after the controller*\n --- | **- routing -** | ---\n `[ci-routesGrp]+Tab` | route Group | *Nesting routes that share the same initial segment.*\n `[ci-routes]+Tab` | simple route | *Like the 'about' route, loading the 'About' Controller*\n `[ci-routesSeg]+Tab` | (:segment) route | *Great for single posts. Match first segment.*\n `[ci-RoutesAny]+Tab` | (:any) route | *Will match everything from the URI*\n `[ci-RoutesNum]+Tab` | (:num) route | *When expecting a numeric segment like xByID/$id*\n `[ci-RoutesAlpha]+Tab` | (:alpha) route | *No numbers*\n `[ci-RoutesAlNum]+Tab` | (:alphanum) route | *Letters and/or numbers*\n `[ci-RoutesHash]+Tab` | (:hash) route | *See the Models Docs for the usage*\n --- | **- Build Responses -** | ---\n `[ci-list-errors]+Tab` | Show validation errors | *Often placed right above the Form*\n `[ci-loop]+Tab` | Looping trough arrays | *That's the PHP version with `foreach` and `/foreach`*\n `[ci-pl]+Tab` | Parsed Loop | *Just a quick `{foo}{bar}{/foo}` to display array elements like news*\n `[ci-e]+Tab` | `\u003c?= $foo ?\u003e` | *Echo out a variable sent by the controller within the $data array*\n `[ci-et]+Tab` | `\u003c?= ?\u003e`| *Just the empty 'EchoTag' in its short version*\n `[ci-var]+Tab` | $foo['bar'] | *Use that inside `ci-loop` to print the variables from the result*\n --- | **- Some Basics -** | ---\n `[ci-t]+Tab` | $this-\u003e | *...preaty self explanatory.*\n\n\n\n### ``[ci-m]+Tab`` Model File\n\nUsual models location: *App/Models/*\n\n\n\nThe meaning of the config settings are in the docs at [CI4 Docs\u003e Modeling Data\u003e Using CodeIgniter's Model](https://codeigniter4.github.io/userguide/models/model.html).\n\nThe exemple function is from the official [\"News section\" tutorial](https://codeigniter4.github.io/userguide/tutorial/news_section.html).\n\n#### Tab steps:\n- ${1:App}  : *In case you changed your app namespace.*\n- ${2:News} : The name of your Model file (always uppercase first letter).\n- ${3:news} : The corresponding database table (lowercase).\n- ${4:id}   : *In case you changed the primary_key*\n- ${0}      : The mouse cursor will end here after last tab.\n\n```php\n\u003c?php namespace ${1:App}\\Models;\n\nuse CodeIgniter\\Model;\n\nclass ${2:News}Model extends Model\n{\n    protected \\$table = '${3:news}';  \n    protected \\$primaryKey = '${4:id}';\n\n    protected $returnType = 'array';\n    protected $useSoftDeletes = false;\n\n    protected \\$allowedFields = ['title', 'slug'];\n\n\t// protected $useTimestamps = false;\n\t// protected $createdField  = 'created_at';\n\t// protected $updatedField  = 'updated_at';\n\t// protected $deletedField  = 'deleted_at';\n\n\t// protected $validationRules    = [];\n\t// protected $validationMessages = [];\n\t// protected $skipValidation     = false;\n\n    // Exemple function to retrive data\n    public function get${2:News}(\\$slug = false)\n    {\n        if (\\$slug === false)\n        {\n            return \\$this-\u003eorderBy('id', 'desc')-\u003efindAll();  // Get all records\n        }\n        return \\$this-\u003easArray()\n                     -\u003ewhere(['slug' =\u003e \\$slug])\n                     -\u003efirst();\n        ${0}                                            // or Get one record\n    }\n\n}\n```\nTo follow along with the official tutorial, create the news table as follow:\n\nWithin phpMyAdmin\n```SQL\nCREATE TABLE news (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        title varchar(128) NOT NULL,\n        slug varchar(128) NOT NULL,\n        body text NOT NULL,\n        PRIMARY KEY (id),\n        KEY slug (slug)\n);\n\nINSERT INTO news VALUES\n(1,'Elvis sighted','elvis-sighted','Elvis was sighted at the Podunk internet cafe. It looked like he was writing a CodeIgniter app.'),\n(2,'Say it isn\\'t so!','say-it-isnt-so','Scientists conclude that some programmers have a sense of humor.'),\n(3,'Caffeination, Yes!','caffeination-yes','World\\'s largest coffee shop open onsite nested coffee shop for staff only.');\n```\n\nIn the .env file from CI root folder:\n```\ndatabase.default.hostname = localhost\ndatabase.default.database = ci4tutorial\ndatabase.default.username = root\ndatabase.default.password = root\ndatabase.default.DBDriver = MySQLi\n```\n\n... that will create a basic news table.\n\n---\n\n### ``[ci-c]+Tab`` Controller File\n\nUsual controllers location: *App/Controllers/*\n\n\nKeeped (commented) the basic stuff needed to get data from a Model,\nthe exemple works with the News model from the official tutorial.\n\nRead the [Controllers Doc](https://codeigniter4.github.io/userguide/incoming/controllers.html) for more details.\n\n#### Tab steps:\n- ${1:App}  : *In case you changed your app namespace.*\n- ${2:News} : The name of your Controller file (always uppercase first letter).\n- ${3:news} : The corresponding database table (lowercase).\n- ${4:id}   : *In case you changed the primary_key*\n- ${0}      : The mouse cursor will end here after last tab.\n\n```php\n\u003c?php namespace ${1:App}\\Controllers;\n\nuse CodeIgniter\\Controller;\n//use App\\Models\\NewsModel;\n\nclass ${2:News} extends Controller\n{\n    public function index()\n    {\n        //\\$model = new NewsModel();\n\n            \\$data = [\n                //'news'  =\u003e $model-\u003egetNews(),\n                'title' =\u003e 'Some title',\n            ];\n\n         echo view('${3:news}/${4:index}', $data);        \n    }      \n}\n```\n\n\n\n### ``[ci-l]+Tab`` Layouts\n\nUsual layouts location: *App/Views/Layouts/*\n\nBasically an HTML skeleton with at least one 'section' inside,\nacting like a placeholder into the views extended from the layout.\n\n```php\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n\t\u003cmeta charset=\"UTF-8\"/\u003e\n\t\u003ctitle\u003eLayout\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\t\u003c?= $this-\u003erenderSection('content') ?\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### ```[ci-v]+Tab``` View\n\nSnippet file: *CI4-Snippets/ci4-view.sublime-snippet*\n\nUsual models location: *App/Views/*\n\nFilling up the sections defined into the layout.\n\n```php\n\u003c?= \\$this-\u003eextend('${1:layouts/main}') ?\u003e\n\n\n\u003c?= \\$this-\u003esection('${2:content}') ?\u003e    \n\n${3:content goes here}\n\n\u003c?= \\$this-\u003eendSection() ?\u003e\n```\n\n\nLicense\n-------\n\nCopyright 2019, Andrei Curelaru \u003candrei@andikod.fr\u003e\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandikod%2Fci-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandikod%2Fci-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandikod%2Fci-/lists"}