Answer the question
In order to leave comments, you need to log in
How to properly include application settings files?
I have a site based on the mvc principle
, there is an Application class, as the basis of the application, with the
$app = new Application();
$app->run();
I launch an application instance, a route is defined there, a controller, a model are connected, a view is displayed
in the config folder, the application settings are stored, this can be information on sessions, a template engine where logs, cache, database connection settings, etc. will be stored, then there is a variety of customizable information that is needed in different parts of the application
in the Model, the connection settings to the database are needed
in the View, the type of templating engine used
, etc., etc.
How to properly organize access of application parts to settings files?
at first I thought to connect them to the Application, which seems logical, but how to transfer the settings to the controller, model? Do I need to create a separate Config class and inherit from it for all parts of the application?
And is there another approach?
Answer the question
In order to leave comments, you need to log in
config - as global array - easiest and fastest.
https://stackoverflow.com/questions/12129066/php-c...define('MYARRAY', array('test1','test2','test3'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question