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

johndoee's avatar

Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' (this will throw an Error in a future version of PHP)

I met this problem

Use of undefined constant ROOT_PATH - assumed 'ROOT_PATH' (this will throw an Error in a future version of PHP) 

how can solve it

 public function themes(){
        $title = __a('themes');

        $current_theme = get_option('current_theme');
        $installed_themes = [];
        foreach (Finder::create()->in(ROOT_PATH.'/themes')->directories()->depth(0) as $dir) {
            $directoryName = $dir->getBasename();
            $themePath = $dir->getPathname();

            $theme_info = include_once $themePath.'/ThemeInfo.php';


0 likes
9 replies
tykus's avatar

how can solve it

Define a const named ROOT_PATH

Or, depending on where this path is in the context of your application; maybe one of the path helper functions would be better???

tykus's avatar

@kyawswar I don't know your application...

depending on where this path is in the context of your application

Where should ROOT_PATH be pointing? Is this a package that you are using?

johndoee's avatar

@Sinnbeck can you show me example , how can define constant ROOT_PATH in laravel or how can use config values as you said.

Sinnbeck's avatar

@kyawswar Constants have nothing to do with laravel. They are a php thing

define('ROOT_PATH', '/app');

And there are examples of config files in the config folder of your laravel app

tykus's avatar
tykus
Best Answer
Level 104

@kyawswar just define it in public/index.php - you will see how the LARAVEL_START is defined in there

1 like

Please or to participate in this conversation.