Welcome Guest, Not a member yet? Register   Sign In
Modules constants
#3

Constants in CI has always been confusing for me. In CI3 I kept them in constants.php but in CI4 I have divided up the different sets of constants (for example DB table names and permission constants) in separate classes. I keep them in app/Libraries:
PHP Code:
<?php

namespace App\Libraries;

class 
Table
{

    public const badge_providers 'badge_providers';
    public const badge_templates 'badge_templates';
    public const brands 'brands';

In code I reference them with Table::brands and rely on the autoloading.
Reply


Messages In This Thread
Modules constants - by ZoeF - 03-07-2021, 07:23 PM
RE: Modules constants - by ZoeF - 03-08-2021, 11:57 AM
RE: Modules constants - by tgix - 03-09-2021, 01:35 AM
RE: Modules constants - by ZoeF - 03-09-2021, 06:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB