CodeIgniter Forums

Full Version: XMLWriter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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();
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();
(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.
(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(); 
(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.
thank you for both of you, and thank you for your time helping me