• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding additional "packages" to Autoload->psr4

#1
I am in the process of learning some of the new ideas in CI4 before it goes live (next year???)
One of my more important libraries is my Package Manager and I am looking into how I can dynamically add to the CI4 $psr4 array and where.

Currently in CI3 my package manager gives a client/user the ability to upload a package or they can simply "composer it in". After which they can use the GUI/CLI to installer/upgrader/uninstaller those packages this is done by modifying the application/config/autoload.php -> $autoload['packages'] array. Of course the current system of loading libraries in CI3 creates a lot of file system scans.

Since we are now using the composer autoloader (ya!) and the autoload configuration file is no longer a simple array (var_export() did a great job there!) what is the best way to add additional namespaces (packages) to the application/Config/Autoload.php $psr4 array()?

I see a public $psr4 in the Autoload.php class and a array_merge at the bottom of the constructor? Is there some where early enough in the bootstrap process I can attach some thing on to that?

One other thing I noticed is that there doesn't seem to be a root path constant like APPPATH or BASEPATH. Since we are now working with a "public" folder by default (ya!). It would be nice to have a constant point to the project root. ROOTPATH or something? Then in my code I don't need to use APPPATH.'/../Orange' like below to attach a namespace.


PHP Code:
$psr4 = [
 
'Config'                     => APPPATH.'Config',
 
APP_NAMESPACE                => APPPATH// For custom namespace
 
'App'                        => APPPATH// To ensure filters, etc still found
 
'Orange'                     => APPPATH.'/../Orange',
 ]; 

It could just be ROOTPATH.'/Orange' or ROOTPATH.'/personal_packages/Orange'

I look forward to your comments.

DMyers
Reply


Messages In This Thread
Adding additional "packages" to Autoload->psr4 - by dmyers - 07-29-2016, 12:09 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.