|
Tom Fitzgerald - 2021-01-13 22:01:22
Hi, I am new to programming, that's why I am trying to use your class, But being *Stupid* I am reading this in the autoloader.php
if (strpos($strTableClass, '\\') > 1) {
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$strInclude = str_replace('\\', DIRECTORY_SEPARATOR, $strTableClass) . '.php';
}
and I just don't understand...
my index is at the root of my site
Your class is copied to the /gcal folder
so what do I put in the '\\'????
I googled namespace but the only hits I get are for XML???
Thanks, in advance, for helping a dummy.
MrFitz
Stefan Kientzler - 2021-01-13 23:13:55 - In reply to message 1 from Tom Fitzgerald
Hi Tom,
If you copy the GCalAddEventLink.php file into another directory (in your case the '\gcal' directory), I recommend you not to use the autoloading function - just include the class directly via
-> require_once("\gcal\GCalAddEventLink.php");
instead of
-> require_once("autoloader.php");
in your script.
If you do so, you don't have to make any further adjustments.
If you want to dive deeper into the topic of 'Namespaces' in PHP, I recommend reading the basic on the PHP Documentation.
php.net/manual/en/language.namespac ...
I also recommend that you take a look at the autoload functionality of PHP in this context.
php.net/manual/en/language.oop5.aut ...
regards, Stefan
Tom Fitzgerald - 2021-01-14 17:01:20 - In reply to message 2 from Stefan Kientzler
Tried that, but now I get this....
my index file is in aqreport.com/dev
thrown in /home3/gasco91119/public_html/dev/gcal/SKien/GCalendar/GCalAddEventLink.php on line 56
[14-Jan-2021 10:48:00 America/Chicago] PHP Fatal error: Uncaught Error: Class 'Psr\Log\NullLogger' not found in /home3/gasco91119/public_html/dev/gcal/SKien/GCalendar/GCalAddEventLink.php:56
Stack trace:
#0 /home3/gasco91119/public_html/dev/AddEventExample.php(9): SKien\GCalendar\GCalAddEventLink->__construct()
#1 {main}
thrown in /home3/gasco91119/public_html/dev/gcal/SKien/GCalendar/GCalAddEventLink.php on line 56
Sorry to be such a dope.
MrFitz
Stefan Kientzler - 2021-01-14 20:38:31 - In reply to message 3 from Tom Fitzgerald
Hi Tom,
Sorry, in my answer yesterday I didn't thought about that the component uses the logger interface :-(
Since you can't work with autoloading, these files from the
/Psr/log - directory of the package
must of course also be integrated manually into your code:
require_once '<your path>/LoggerInterface.php';
require_once '<your path>/AbstractLogger.php';
require_once '<your path>/NullLogger.php';
regards, Stefan
PS:
The fact that all these 'require_once xxx' are not needed with correct autloading shows how powerful this mechanism can be :-)
But for this to happen, various conditions regarding directory name, namespace and class name must be met, which is no longer the case due to the shift to other directories!
Tom Fitzgerald - 2021-01-17 14:36:07 - In reply to message 4 from Stefan Kientzler
Thanks, That did it!
MrFitz
|