-Create a folder in project root directory or app directory.
I am creating a folder with name Includes in App folder:(C:xampp/htdocs/ci4/App/Includes)
-Create a file CustomConstants.php, and define your constants in that file.
Save the file inside Includes folder
-use include or require method to include that file into your controllers, which contains your constants
require APPPATH.”/includes/CustomConstants.php”;

if you want to use custom constants every where in your project, then include the file in App/Config/App.php. if your include your file here, we no need to include that file everywhere. because this location global

require APPPATH.”/includes/CustomConstants.php”;
class App extends BaseConfig
{
//App class
}