You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my Goldmont.System plugin, there's a class named Docker which I use to read Docker secrets and to set the values into the project config. Today, I needed to read AWS S3 credentials in order to setup a new resource storage in cms.php. However, for some reason, the Docker class is not loaded by the autoloader yet. Furthermore, this problem exists only in cms.php file. The Docker class is properly loaded when I use it in filesystems.php file. What's going on? Isn't the autoloader run before everything?
Since your directory is named in lowercase, your namespace should also be in lowercase. You should have some warnings from Composer's autoloader concerning PSR4 standards. I highly recommend changing the directory name to an uppercase H instead of changing the namespace though, as it's also part of PSR conventions.
@nmiyazaki-chapleau we actually do support the folders being lowercase and the class file being TitleCase, it's what all the first party modules and plugins do and it's what the scaffolding generates.
@goldmont as for your original issue this is known and intentional. The config loader loads those files when the values are asked for. Plugin classes are not autoloaded until the plugin itself is registered and determined to be enabled so that disabled plugins do not have their code autoloaded.
Since the System ServiceProvider loads the cms.loadModules config item in order to determine which modules to load and register before it kicks off the plugin initialization it's expected that any plugin provided classes would not be loaded at that point.
The solution is to make use of Config::set() to set the value from within your plugin's register() or boot() methods instead of referencing your plugin classes from your project's configuration files.
Furthermore at some point in the future we plan on refactoring how the CMS storage is configured so that it'll be done as real disks in filesystems.php instead of the current setup in the CMS config, so if you're interested in helping out with that I'd point you at #844 and wintercms/storm#141
Winter CMS Build
1.2
PHP Version
8.1
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
Hi,
In my
Goldmont.System
plugin, there's a class namedDocker
which I use to read Docker secrets and to set the values into the project config. Today, I needed to read AWS S3 credentials in order to setup a new resource storage incms.php
. However, for some reason, theDocker
class is not loaded by the autoloader yet. Furthermore, this problem exists only incms.php
file. TheDocker
class is properly loaded when I use it infilesystems.php
file. What's going on? Isn't the autoloader run before everything?Plugin structure:
. <-- Goldmont.System
├── helpers <-- LOWER CASE
│ ├── Docker.php <-- NAMESPACE: Goldmont\System\Helpers
Error:
Class "Goldmont\System\Helpers\Docker" not found
Steps to replicate
Workaround
No response
The text was updated successfully, but these errors were encountered: