Skip to content

docs: improve helpers.rst#7032

Merged
kenjis merged 5 commits intocodeigniter4:developfrom
kenjis:fix-docs-helpers.rst
Dec 28, 2022
Merged

docs: improve helpers.rst#7032
kenjis merged 5 commits intocodeigniter4:developfrom
kenjis:fix-docs-helpers.rst

Conversation

@kenjis
Copy link
Copy Markdown
Member

@kenjis kenjis commented Dec 28, 2022

Description

  • add note for case sensitive file system and namespace

See https://forum.codeigniter.com/showthread.php?tid=85977

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • User guide updated
  • [] Conforms to style guide

@kenjis kenjis added the documentation Pull requests for documentation only label Dec 28, 2022
Copy link
Copy Markdown
Contributor

@datamweb datamweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A long time ago, I had used namespace to write the helper, which caused the helper not to load.

<?php

declare(strict_types=1);

namespace App\Helpers;

if (! defined('myhelper')) {

    function myhelper() 
    {
        return 'XX';
    }
}

Maybe adding a note or warning would be nice. But I'm not sure if anyone other than me will repeat this funny mistake.

@kenjis
Copy link
Copy Markdown
Member Author

kenjis commented Dec 28, 2022

Oh, it was loaded!

        helper('myhelper');
        \App\Helpers\myhelper(); // returns 'XX'

Copy link
Copy Markdown
Contributor

@datamweb datamweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\App\Helpers\myhelper(); // returns 'XX'

I used it like this.

helper('myhelper');
myhelper();

And I had this error:

Call to undefined function App\Controllers\myhelper() 

I understand how to use.
Thank you @kenjis .

@kenjis kenjis merged commit 1973c35 into codeigniter4:develop Dec 28, 2022
@kenjis kenjis deleted the fix-docs-helpers.rst branch December 28, 2022 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Pull requests for documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants