Custom Extensions and Web Root Folder in PHP

I downloaded and manually installed the writeAndReadFileModules extension in both extensions folders as follows.:

extensions
www (Web Root Folder)
-extensions (inside the Web Root Folder)

In Wappler, it would not recognize the extensions folder inside the Web Root Folder in order for the extension to appear. It would not execute on the frontend unless the extensions folder is inside the Web Root Folder. Thus, I have 2 identical extensions folders. Shouldn't Wappler use the extensions folder in the Web Root Folder in both instances? It appears that Wappler is not factoring in the Web Root Folder location.

Possible bug in PHP model?

PS: I tried to install it using Project Settings > Extensions > New Extension, but got lost so I went with manual installation.

1 Like

BUMP

still not fixed, extensions still needs to be installed in parent folder

is this for specific PHP server side extensions or for client side app connect extensions?

Sorry, this is server side for me, not tried any app connect

Basically i have to put the extensions folder in the ftp root to get the HJSON recognised but have to duplicate the extensions folder in www to have the associated php function run.

Same as Brian.

to clarify, hjson file needs to be in site root extensions folder, .php in www/extensions folder

This is only when you have manual extension installation or during extension development.

Have you tried to install from npm? Just as other server connect extensions but then with php files?

Have not got past that stage, still developing so yes.

I kind of promised myself I would never use PHP again but am trying to remake one of my extensions in PHP as a favour to someone.

This is the first time i have fired up a PHP project in a few years. This www bit is all new to me!

So no, i have not tried install from npm as i have not got to that stage, in fact i didn't realise you could, always assumed npm was node only.

All my stuff except one testing sandbox are PHP and I don't even have a www folder. So I can't even install any third party extensions. :frowning:

In tried the php own server first which i have seen on the forum creates a www folder.

After the issues i though i would resolve this by switching to own server and using Wamp.
It still created www sub folder inside the local project root which frankly suprised me

Is this not your normal experience with wappler? It creates www subfolder then remaps the site root to the www subfolder

That interesting

I assumed the issue was at run time the app looked for the .php file within the web root extensions folder which is the expected behaviour

But had assumed the bug was the that wappler wrongly looked for the hjson file in the site root, one level above the web root.

But if your web root is also your project root rather than being in a sub folder i assumed the extensions would work as expected

We have moved all new php projects to use a www subfolder for webroot, already for some time now. Just as we already do for NodeJS and mobile projects.

Existing project can also be migrated by just entering www as webroot folder in the project options, the files will be move there then.

There are many advantages to have the web files in separate subfolder, so we can but project related build artifacts and extension files in the main folder that are not needed on the live website.

But some users like @brad just never switched :slight_smile:

i get that, my confusion is why he cant install third pary extensions?

If his project root and web root are the same, i would not expect this bug to effect him?

Also @george, can you confirm PHP extensions can be sent to the npm repository and the method is the same as node? I didn't realise that was an option.

I never switched to what @George ?

All of my projects were created pre Wappler 6 and did not create the www folder.

Are you saying I can just enter www in the setting and my files will be moved there? How does that affect my targets? Do I manukau have to create a www folder on them to? Or does the www folder get ignored on publish?

1 Like

Yes Wappler php extensions canine also fully installed with npm. That is why we require that you have a www folder as a webroot so that is what is uploaded to your live website and not any files outside of it so we can fully have there own node_modules as well other build tools

1 Like

guess i need to go back and add a "node" tag to all my extensions now :smile:

Unfortunately, this is not true. you can't add a www setting. It forces you to look for a folder.

well in the hjson action definition you can add per action for which server models it is supported.

So for node only you can add:

serverModel: ['node'],

if also php is supported, just add it as well (might the case)

serverModel: ['node', 'PHP'],

Same is also valid for ASP.NET and ASP

if the serverModel property is missing then the action is available for all server models.

Not sure if this is mentioned in the extensibility docs, if not you can add it.

No, not mentioned. I will add it

So i just add "serverModel: ['node', 'PHP']," to the head of the HJSON, put the .js and .php files in the same place and npm will install for both platforms.

So i simply have this

image