oskar.villani40843 said:
Found an interesting behaviour of octoberCMS - or is this quite usual?
When my path to my class is ./plugins/oskar/tutorial/classes (notice: all in small letters) then usually I write:
use Oskar\Tutorial\Classes...
for the path with capital initial letter. But the name of the class file itself has to be written in the 'use' statement as the .php file is written.
// if class php file is named MyClass.php
use Oskar\Tutorial\Classes\MyClass
// if class php file is named myclass.php
use Oskar\Tutorial\Classes\myclass
Hi Oskar,
I'm glad to have been able to help you and of course I will check the site you've linked and I will post the tutorial there too.
The mentioned behaviour regarding case-sensitivity is not related to OctoberCMS itself but to PHP - however it works like this because of the default settings of class autoloading in OctoberCMS as it uses PSR-4 naming conventions.
OctoberCMS autoloads classes from all "plugins/..author../..pluginname../classes" (base) directory automaticaly so they are available instantly but you always have to keep in mind the PSR-4 rules. (I've pointed it in my tutorial above too ;))
You can see details here: https://www.php-fig.org/psr/psr-4/
You can use any kind of letters in the path part of the namespace because that part ("Oskar\Tutorial\Classes") is the "base directory" for autoload but under "classes" folder you will need to use capital folder/file names then you have to use capital folders/files in the namespace definitions too.
ps.: If you would use IIS (or any other Windows based system) in the future then you will find that it is NOT case-sensitive (it finds the file even if it does not match capital letters) but I suggest to always use PSR-4 rules even on IIS because you will face some serious issues in case you would move and migrate your code to Linux based environment - trust me it's personal experience. :)