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

Hello !

I'm converting an application from Codeigniter 3 to 4.
I've wrote some functions dealing with files and with Codeigniter 4 the php funtion "RecursiveDirectoryIterator" cannot be found anymore :


Quote:CRITICAL - 2020-04-18 16:14:49 --> Class 'App\Controllers\RecursiveDirectoryIterator' not found



Is that my server config or a new Codeigniter 4 security limitation ?
I understant that Codeigniter limits his searching into the App\Controllers subfolder. Am I obliged to use the filesystem helper ?
I've got the same problem with DateTime functions and I finally use Time helper but there's a little bit more of code to check associated to "RecursiveDirectoryIterator"...

Thanks !

PS : sorry for my english
Reply
#2

Put a \ in from of all native PHP functions and you are gold.

\RecursiveDirectoryIterator instead of RecursiveDirectoryIterator
\DateTime instead of DateTime

CodeIgniter are trying to find an internal function and not the global ones.
Reply
#3

It works great thanks !!
Maybe it could be a good idea to mention it on the user guide ? I've searched with "php native function" and I didn't find this obvious trick.

Thanks again for this fast answer !
Reply
#4

Hi, I will see if I find a good place for it. I'm currently doing other updates to the manual, so it may take some time I'm afraid.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB