Best way to define path in PHP -


this piece of code

define('base_path', realpath(__dir__) . directory_separator);  define('lib', base_path . 'lib' . directory_separator);     define('framework', lib . 'framework' . directory_separator);         define('database', framework . 'database' . directory_separator);         define('datetime', framework . 'datetime' . directory_separator);         define('autoloader', framework . 'autoloader' . directory_separator);         define('functions', framework . 'functions' . directory_separator);         define('router', framework . 'router' . directory_separator);  define('inc', base_path . 'inc' . directory_separator); define('admin', base_path . 'admin' . directory_separator); define('ext', base_path . 'ext' . directory_separator);     define('modules', ext . 'modules' . directory_separator);     define('plugins', ext . 'plugins' . directory_separator);     define('themes', ext . 'themes' . directory_separator);  class path {     public $paths = array(         'cms' => base_path,         'cms\lib' => lib,         'cms\framework' => framework,         'cms\framework\database' => database,         'cms\framework\datetime' => datetime,         'cms\framework\functions' => functions     ); } 

as can't use function or concatenating string in class path property (php don't allow this), define path first, using definition on array values of property.

is right ? there better solution ?
p.s. use class path give base path each namespaces (i want use on psr4 autoloader) and, don't call autoloader register namespace because think it's better separate it.. so, if client wants change path, doesn't need see business logic

you can create config file, think syntax lot more friendly

config files in php


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -