Welcome Guest, Not a member yet? Register   Sign In
How to call function from custom helper ?
#1

On codeigniter 4.3.7 site I need to create a custom helper so I created a file app/Helpers/helper.php with code:

PHP Code:
<?php

namespace App\Helpers;

const 
DATE_FORMAT '%B %d, %Y';

function 
formatDateTime($DateTimeLabel ''$format '')
{
... 

I try to call this method from view file app/Views/admin/categories/index.php:

PHP Code:
<?php helper('helper'); ?>
<?= $this
->extend("layouts/default"?>

<?= $this->section('content'?>

<td><?= formatDateTime($category['created_at'], "ASTEXT"?></td> 

But I got error that function formatDateTime not found even after in app/Config/Autoload.php I added ref to my helper file :


PHP Code:
public $helpers = [
'app/Helpers/helper.php'
]; 

Have I to run some console commands to use my helper ?

Thanks in advance!
Reply


Messages In This Thread
How to call function from custom helper ? - by petrogromovo - 10-02-2023, 07:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB