List of path constants I have a file called paths.php which is the first file that loads on every page request. I read that I should make a constant of the root folder path but not for every file, but the main point why I did constants for commonly used paths: when the path changes I don't need to go around different files changing require(ROOT . &quot;/path/to/file&quot;); instead all I need is to change the constant value. The path constant list is building up fast and every time I open that file I feel that something is not right and something needs to be changed so I decided to ask my first question here. I heard about autoloading, but by my (small) knowledge it's only for OOP projects (please fix me if I'm wrong)? This project is done without OOP only for practice purposes, I want to make at least one non-oop page and then move on to OOP.
So here is the code, I hope to get criticism, tips, and what should I change or do differently with arguments so I can learn.
This is not a full file, just a part of it - modules/templates paths
// 04.
defined(&quot;MODULES&quot;) or define(&quot;MODULES&quot;, RESOURCES . &quot;/modules&quot;);
defined(&quot;FUNCTIONS&quot;) or define(&quot;FUNCTIONS&quot;, MODULES . &quot;/functions.php&quot;);
defined(&quot;AUTH&quot;) or define(&quot;AUTH&quot;, MODULES . &quot;/authentication&quot;);
defined(&quot;AUTH_CONTROL&quot;) or define(&quot;AUTH_CONTROL&quot;, AUTH . &quot;/auth-control.php&quot;);
defined(&quot;SIGN_UP&quot;) or define(&quot;SIGN_UP&quot;, AUTH . &quot;/sign-up.php&quot;);
defined(&quot;SIGN_IN&quot;) or define(&quot;SIGN_IN&quot;, AUTH . &quot;/sign-in.php&quot;);
defined(&quot;FORMS&quot;) or define(&quot;FORMS&quot;, MODULES . &quot;/forms&quot;);
defined(&quot;FORM_CONTROL&quot;) or define(&quot;FORM_CONTROL&quot;, FORMS . &quot;/form-control.php&quot;);
defined(&quot;FORM_ERRORS&quot;) or define(&quot;FORM_ERRORS&quot;, FORMS . &quot;/form-errors.php&quot;);
defined(&quot;FORM_VALIDATION_FUNCTIONS&quot;) or define(&quot;FORM_VALIDATION_FUNCTIONS&quot;, FORMS . &quot;/form-validation-functions.php&quot;);
defined(&quot;UPLOAD_IMG&quot;) or define(&quot;UPLOAD_IMG&quot;, MODULES . &quot;/upload-image.php&quot;);

// 05.
// Templates Folder
defined(&quot;TEMPLATES&quot;) or define(&quot;TEMPLATES&quot;, RESOURCES . &quot;/templates&quot;);
// Main Templates
defined(&quot;MAIN_TEMPLATES&quot;) or define(&quot;MAIN_TEMPLATES&quot;, TEMPLATES . &quot;/main-templates&quot;);
defined(&quot;HEAD&quot;) or define(&quot;HEAD&quot;, MAIN_TEMPLATES . &quot;/head.php&quot;);
defined(&quot;HEADER&quot;) or define(&quot;HEADER&quot;, MAIN_TEMPLATES . &quot;/header.php&quot;);
defined(&quot;BANNER&quot;) or define(&quot;BANNER&quot;, MAIN_TEMPLATES . &quot;/banner.php&quot;);
defined(&quot;FOOTER&quot;) or define(&quot;FOOTER&quot;, MAIN_TEMPLATES . &quot;/footer.php&quot;);
defined(&quot;JS_FILES&quot;) or define(&quot;JS_FILES&quot;, MAIN_TEMPLATES . &quot;/js-files.php&quot;);
// Content Templates
defined(&quot;CONTENT_TEMPLATES&quot;) or define(&quot;CONTENT_TEMPLATES&quot;, TEMPLATES . &quot;/content-templates/&quot;);
// Form Templates
defined(&quot;FORM_TEMPLATES&quot;) or define(&quot;FORM_TEMPLATES&quot;, TEMPLATES . &quot;/form-tmp&quot;);
If this is the first thing that loads on every page, then the chance of any of these constants being already defined is very small. Why then define them conditionally? These are constants, they should always have the same value. Therefore you can change:
defined(&quot;CONSTANT2&quot;) or define(&quot;CONSTANT2&quot;, CONSTANT1 . &quot;/constant2&quot;);

to:
define(&quot;CONSTANT2&quot;, CONSTANT1 . &quot;/constant2&quot;);

One of the reasons to define constants conditionally is that you don't want to overwrite constants that are part of PHP. In my opinion there is a better way to prevent this: Choosing longer constant names. So instead of calling a constant HEAD, you could call it TEMPLATE_HEAD. That way the chance of a naming collision is reduced.
Since PHP 5.3 from 2009 is has been possible to define global constants this way:
const CONSTANT2 = CONSTANT1 . &quot;/constant2&quot;;

I know it is purely subjective, but I prefer this syntax. Later, when you start using OOP this will be the only syntax for class constants.
Given the above your code could look like this:
// 04.
const FOLDER_MODULES            = FOLDER_RESOURCES . '/modules';
const MODULE_FUNCTIONS          = FOLDER_MODULES . '/functions.php';
const FOLDER_AUTH               = FOLDER_MODULES . '/authentication';
const AUTH_CONTROL              = FOLDER_AUTH . '/auth-control.php';
const AUTH_SIGN_UP              = FOLDER_AUTH . '/sign-up.php';
const AUTH_SIGN_IN              = FOLDER_AUTH . '/sign-in.php';
const FOLDER_FORMS              = FOLDER_MODULES . '/forms';
const FORM_CONTROL              = FOLDER_FORMS . '/form-control.php';
const FORM_ERRORS               = FOLDER_FORMS . '/form-errors.php';
const FORM_VALIDATION_FUNCTIONS = FOLDER_FORMS . '/form-validation-functions.php';
const IMAGE_UPLOAD              = FOLDER_MODULES . '/upload-image.php';

// 05.
// Templates Folder
const FOLDER_TEMPLATES          = FOLDER_RESOURCES . '/templates';
// Main Templates
const FOLDER_MAIN_TEMPLATES     = FOLDER_TEMPLATES . '/main-templates';
const TEMPLATE_HEAD             = FOLDER_MAIN_TEMPLATES . '/head.php';
const TEMPLATE_HEADER           = FOLDER_MAIN_TEMPLATES . '/header.php';
const TEMPLATE_BANNER           = FOLDER_MAIN_TEMPLATES . '/banner.php';
const TEMPLATE_FOOTER           = FOLDER_MAIN_TEMPLATES . '/footer.php';
const TEMPLATE_JAVASCRIPT       = FOLDER_MAIN_TEMPLATES . '/js-files.php';
// Content Templates
const FOLDER_CONTENT_TEMPLATES  = FOLDER_TEMPLATES . '/content-templates/';
// Form Templates
const TEMPLATE_FORM             = FOLDER_TEMPLATES . '/form-tmp';

Somehow I find this much easier on the eyes.