Welcome Guest, Not a member yet? Register   Sign In
Use library without namespace
#1

Hi , i want use this php library :

https://github.com/s2software/fatturapa

if i add namespace to FatturaPa.php (renamed ) i have this error :
Class 'App\ThirdParty\Fatturapa\DOMDocument' not found
this is the error row :
471        $doc = new DOMDocument();
if i load with require_once: require_once (APPPATH.'/ThirdParty/Fatturapa/FatturaPA.php');
folder three:
https://imgur.com/KLiuofM.png
i have thi error :
Class 'App\Controllers\FatturaPA' not found

how can i use the library ?
471         $doc = new DO
471        $doc = new DOMDocument();MDocument();
Class 'App\ThirdParty\Fatturapa\DOMDocument' not found Class 'App\ThirdParty\Fatturapa\DOMDocument' not found 
Reply
#2

Without adding the namespaces.
Or adding the correct namespaces in all files.

It seems you need to learn PHP's namespaces and PSR-4 autoloader.
Reply
#3

app/Config/Autoload.php
classmap property

Don't force the namespace in someone else's library.
Reply
#4

(01-31-2022, 05:04 PM)kenjis Wrote: Without adding the namespaces.
Or adding the correct namespaces in all files.

It seems you need to learn PHP's namespaces and PSR-4 autoloader.

There is only one file DOMDocument is a PHP function
Reply
#5

PHP internal class is located in global namespace.
See https://www.php.net/manual/en/language.n...llback.php
Reply
#6

(This post was last modified: 02-06-2022, 04:22 AM by pippuccio76.)

(01-31-2022, 05:12 PM)iRedds Wrote: app/Config/Autoload.php
classmap property

Don't force the namespace in someone else's library.

Removed namespace . 
In config Autoload :

Code:
public $classmap = [


'FatturaPA' => APPPATH.'/ThirdParty/Fatturapa/FatturaPA.php',

];

same error : https://imgur.com/Xux8b27.png

This is my folder three : https://imgur.com/Y886AbM.png
Reply
#7

use FatturaPA;
Reply




Theme © iAndrew 2016 - Forum software by © MyBB