Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nhayder's avatar
Level 13

Custom helper files ar not working on shared hosting account

i have 3 files added to composer.jason file

        "files" :[
            "App/Helpers/activeAdminSidebar.php", 
            "App/Helpers/messages.php",
            "App/Helpers/isOnline.php"
        ]

The app is fully active on a share hosting account (working perfectly ) except when these 3 files are called withen the app. at that poing im getting this error

Call to undefined function setMainButton() (View: /home/demolinx/resources/views/layouts/sidemenu.blade.php) (View: /home/demolinx/resources/views/layouts/sidemenu.blade.php) (View: /home/demolinx/resources/views/layouts/sidemenu.blade.php)

the setMainButton() is defined in one of the helpers files, Clearly the helper file are not loaded correctly this is why i'm getting these errors.

so my question is? how to reload the helper file on shared hosting using ssh ????

NOTE : composer dump-autoload + composer install is not fixing it for me

0 likes
5 replies
Snapey's avatar
Snapey
Best Answer
Level 122

If this works locally, carefully check the letter case of all the files compared to composer.json

3 likes
siangboon's avatar

Agreed with Snapey. I experienced once, it's case sensitive in linux.

3 likes
nhayder's avatar
Level 13

@SNAPEY - Thank you for your note, i checked the files and it looks like they are matching,

// files in Helpers folder are (Helpers/)
1- activeAdminSidebar.php
2- isOnline.php
3- messages.php

on composer.jason i have them declared like this

    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        },
        "files" :[
            "App/Helpers/activeAdminSidebar.php", 
            "App/Helpers/messages.php",
            "App/Helpers/isOnline.php"
        ]
    },

How i setup the APP on shared hosting is this

outside public_html i have create a folder called demo where i'm storing all laravel files in, as for public folder

i'm using default public_html folder to place laravel public files instead the default public folder that comes with laravel.

also i have updated the index.php files in public_html like this

require __DIR__.'/../demo/vendor/autoload.php';

and 

$app = require_once __DIR__.'/../demo/bootstrap/app.php';

the app is working perfectly on localhost, and on shared account, but every time the app needed any helper functions it breaks,

error sample


Call to undefined function setMainButton() (View: /home/demolinx/demo/resources/views/layouts/sidemenu.blade.php) (View: /home/demolinx/demo/resources/views/layouts/sidemenu.blade.php) (View: /home/demolinx/demo/resources/views/layouts/sidemenu.blade.php)

the setMainButton() function is available on one of the helpers files (activeAdminSidebar.php)

// this is my activeAdminSidebar.php file
<?php

function setMainButton($path){

    return Request::segment(3) === $path ? 'active' : '';

}

function setArrow($path){

    return Request::segment(3) === $path ? 'collapse show' : 'collapse';

}

function activeGroup($path){
    // groupe set
    return Request::segment(3) === $path ? '' : 'collapsed';

}

function setCollapsed($path){
    // collpsed icon function
    return Request::segment(4) === $path ? '' : 'collapsed';

}

function setActive($path){

    return Request::segment(4) === $path ? 'active' : '';

}


Do you see anything in my setup that might cause this type of errors.

nhayder's avatar
Level 13

@SNAPEY - I made the App like this app, then run composer dump-autoload and it worked

"files" :[
            "app/Helpers/activeAdminSidebar.php", 
            "app/Helpers/messages.php",
            "app/Helpers/isOnline.php"
        ]

@snapey You are awesome :-) thank you man

krisssachin's avatar

@snapey @siangboon last week I faced the issue, I was so upset, but today after seen your comment I went to the composer.json and check the spellings. voila found it, it was Helpers and in composer json I wrote helpers.

I love programming

1 like

Please or to participate in this conversation.