The use of PHP within a resource

Hello fellow developers,

I am making a new phone for my fivem server. I tried dynamically loading js files because i want an app to be a module for the phone.

but there is a slight problem when i’m doing this with javascript because the when the file has loaded before actually opening the app it deletes the old instance of the app class and creates an new one in a file that is reloaded after loading the js file of the app you are currently using.

I tested this and it works fine only to notice that the unused file of the old app class instance stays in memory while testing this ain’t really a problem but i am afraid that this might cause trouble for the client when they play for lets say 4/5 hours straight and their memory is full with unused files. So this brought me to the following question.

Is there any way to use PHP directly in a resource without loading the phone in an iframe from a webserver?

I know i cant send nui messages directly to lua and all that. I’m just wondering if this is possible so i’m able to load the applications like modules this way i am able to make the phone opensource with some base applications and be able to sell the extra’s. next to this the phone stays copy pasta proof for the people who do not have a lot of experience and its also easy for those who do.

If any one knows anything about this and you would be so kind to help me out let please let me know below.

thanks already, Sm1Ly :slight_smile:


Solution to my problem with loading the modules, not for the php part of the story.

Hey Sm1Ly :slight_smile:

I have asked a similar question.

And the answer is no you can’t run php

Thanks mate, do you prehabs know an other approach to this problem?

The only way is to make a website and then just preview the website ingame if its because you need some things from ingame you can always connect you website with fivem servers database

I’m not sure if PHP works for that, but you should use React or something other than PHP.

PHP is pure shit in my opinion and React/Angular/NextJS is just superior and easier to use, faster and more reliable.

Just going to expand on this.

if you need php to handle something. you can use a web request to the php page to pass data to the form or just embed the page on a webhost into the resource html and use the hosted page as the actual form system

basically just use the resource as a bridge between fivem and the php system or whatever other software you wish to integrate with (say discord or w/e)

(for the mods. sorry if i shouldnt have bumped this but i felt some clarification may have been useful)