Welcome Guest, Not a member yet? Register   Sign In
XMLWriter
#1

i'm trying to use the XMLWriter from PHP in a CI4 project, but it throws this error:

Class 'App\Models\XMLWriter' not found


this project was working fine on CI2, but i'm trying to redo the whole system using CI4

this is the code where it fails:

$xml = new XMLWriter();
Reply
#2

(This post was last modified: 01-26-2021, 11:06 PM by iRedds.)

In your code implementation, the class autoloader looks for the XMLWriter class in the app/Models directory.
This class is not in the catalog, or it does not have an App\Models namespace defined.

not enough information

There is no class autoloader in CI < 4, so you couldn't load the class simply by writing $xml = new XMLWriter();
Reply
#3

(01-26-2021, 11:04 PM)iRedds Wrote: In your code implementation, the class autoloader looks for the XMLWriter class in the app/Models directory.
This class is not in the catalog, or it does not have an App\Models namespace defined.

not enough information

There is no class autoloader in CI < 4, so you couldn't load the class simply by writing $xml = new XMLWriter();

that is the way in which i'm trying to load it, as if i was loading the PHP extension, but it is not working, i don't know why CI4 thinks that i'm trying to use a CI4's class, i already reviewed the extension in the server and it looks like that extension is enabled and running, any help/hint will be appreciated, thanks.
Reply
#4

(01-27-2021, 12:06 AM)g3ck0 Wrote:
(01-26-2021, 11:04 PM)iRedds Wrote: In your code implementation, the class autoloader looks for the XMLWriter class in the app/Models directory.
This class is not in the catalog, or it does not have an App\Models namespace defined.

not enough information

There is no class autoloader in CI < 4, so you couldn't load the class simply by writing $xml = new XMLWriter();

that is the way in which i'm trying to load it, as if i was loading the PHP extension, but it is not working, i don't know why CI4 thinks that i'm trying to use a CI4's class, i already reviewed the extension in the server and it looks like that extension is enabled and running, any help/hint will be appreciated, thanks.
try

PHP Code:
$xml = new \XMLWriter(); 
Reply
#5

(01-27-2021, 12:06 AM)g3ck0 Wrote: that is the way in which i'm trying to load it, as if i was loading the PHP extension, but it is not working, i don't know why CI4 thinks that i'm trying to use a CI4's class, i already reviewed the extension in the server and it looks like that extension is enabled and running, any help/hint will be appreciated, thanks.

God. My bad.
XMLWriter is the default php class.
Use a backslash before the class name. Like \XMLWriter.
This means that the class is in the global namespace.
Reply
#6

thank you for both of you, and thank you for your time helping me
Reply




Theme © iAndrew 2016 - Forum software by © MyBB