Welcome Guest, Not a member yet? Register   Sign In
Path class instead of inline definitions and usages..
#1

(This post was last modified: 02-24-2016, 07:20 AM by sv3tli0.)

I want to suggest to be created one Path class.
Instead of the current definition of SYSPATH, APPPATH and etc.. 

It can be really useful at the same time from the Autoloader and from developers when they need a specific path..
The fast usage which I can think for is : 
Code:
Path::app()->get('views/home/welcome') - which will return the full path of this application file
Path::app()->view('home/welcome') - alias ..
Path::sys()->get('config/database') - which will return the full path of this sys class file
Path::vendor()->get('somecomposer/project/file') - when composer is used this can return full path for this

In that case the app() method will return an instance of the sub class AppPath which can have methods for each type of file which exists there (controllers/models/libs/views..), same for SysPath and perhaps even a VendorPath if composer is used inside the project..

This change can reflect and inside the index.php file which has too much definitions at the moment.
I think that inside this index.php should be a lot smaller with just setting the app ENV / DEBUG (levels) and registering the Paths.
And that can be a lot easier if it is a class with default settings for sys and app (not variables which later are defined as constants)..

P.S. At the same time this file path class can provide a check if the file exists, perhaps and even a permissions check..
Best VPS Hosting : Digital Ocean
Reply




Theme © iAndrew 2016 - Forum software by © MyBB