Php 8.2 Google App Engine(Flexible Environment)--JS and CSS file inclusion Not Working

GM,
 
   I deployed my application in GAE with php 8.2.My deployment successfully finished.My index page also came. But I included some jquery files and other css,bootstrap and all in my application.. That and all not working.
 
Pls give me the solution for php 8.2 deployment
 
My app.yaml
 
runtime: php
env: flex
service: uat

runtime_config:
operating_system: "ubuntu22"
document_root: .





manual_scaling:
instances: 1




handlers:

- url: .*
script: index.php
# login: required

My Index.php

<?php

echo phpinfo();

?>
<html>

<head>
<script src="JS/jquery-3.6.4.min.js"></script>

<script>

$(document).ready(function(){


alert('inside');

})


</script>
</head>
In my sample I included JS file and in document ready i put alert for checking.
This is my file structure.
phpsample.png
Am waiting for your valuable response.


1 55 4,468
55 REPLIES 55

Hello @safiyullah,

Welcome to the Google Cloud Community!

You can try the following troubleshooting options:

  1. Specify the PHP for the App Engine standard environment, declare the runtime php82 since you're using PHP 8.2 in the app.yaml file.
    runtime: php82
  2. Read about App Startup, as you will need to deploy a front controller to handle all request routing.
  3. Take a look at this Guide Structure in building your application. Check Initializing the app and defining front controllers
  4. If the above options don't work, you can contact Google Cloud Support to further look into your case.

Let me know if it helped, thanks!

Hi,

     Thanks for your valuable response.As per Your Solution, your telling about App Engine Standard Environment.But My case in App Engine Flexible Environment.

runtime: php
env: flex
service: uat

runtime_config:
operating_system: "ubuntu22"
document_root: .

handlers:

- url: .*
script: index.php

They are telling 

For PHP version 7.4 and later, the source code is located in the /workspace directory instead of the root directory (/).

What is that workspace , how to mention that in app.yaml.

My app index.php only working...Whatever folder I included in my app , not working.

Hi,

Can you please tell, how to use php 8.2 in App engine Flexible environment.Pls tell me the soution for my question.I didn't get any solution yet for past one month.

 

Hi, 

I am waiting for your solution for the past 2 month.

 

Pretty sure it's an issue to do with the nginx conf. There is a rewrite rule that takes it directly to index.php/?$1 - see my post; https://www.googlecloudcommunity.com/gc/Serverless/Flexible-PHP82-nginx/m-p/620797#M1994

HI,

I want to deploy my application in GAE php 8.2(Flexible Environment).I opened my issue in Aug. But Still i didn't get any solution.Pls consider my request.

The issue is to do with the nginx config - https://www.googlecloudcommunity.com/gc/Serverless/Flexible-PHP82-nginx/m-p/620797#M1994 I have written a detailed explanation but basically at the VERY top of the flexible nginx default config there is the rewrite rule - I reached out to the very unhelpful support and was told to come here.

rewrite	^/(.*)$	/index.php$uri;

 

 

Hello Community Members,

I have Posted my queries about PHP 8.2 Flexible Envirnment Deployment last month,Still I didn't get any reply.

It is affecting my production process.Google App Enginesaid till July only Php 7.3 will work like that ,So before that we have to prepare and check our Application in PHP 8.2.

Pls consider our issue seriously and response.

Waiting for your valuable reply.

Hi,

I am waiting for your valuable solution. Because I have to upgrade My application from php 7.3 to php 8.2.(As per GAE)

 

 

document_root: public

Document root should be public. This is the folder having your CSS, JS and other assets.

Hi Vipin,

I tried as per your solution, that also not working.My JS and CSS folder not included in my page.

App.yaml

runtime: php
env: flex
service: uat

runtime_config:
operating_system: "ubuntu22"
document_root: public



handlers:

- url: .*
script: index.php

test.png

 

My index.php

<?php


include "Common/Common.php";


$url='JS/jquery-3.6.4.min.js';
echo '<a href='.$url.'>Link</a>';

echo $title;

?>
<html>

<head>
<script src='JS/jquery-3.6.4.min.js'></script>
<link rel="stylesheet" href ="CSS/StyleSheet.css" />


<script>

$(document).ready(function(){


alert('inside');

})


</script>
</head>
<body>
</body>
</html>

 

Did you look at the browser network (Under developer tools) output? I am facing similar issue with PHP8, GCP Flex deployment of Laravel Project. I noticed that the console logs were showing incorrect MIME type error for my CSS and JS files

Also, the handlers will not working in flex deployment. I think it is not needed.

HI,

I looked browser network (Under developer tools) output,

JS/jquery-3.6.4.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.

For me also like that only showing.

Is there any solution to inculde js and css files.. In php 7.3 same script working.Php 8.2 GAE Flexible Environment only not working

 

 

I have not found a solution for it yet. Can we connect via Skype? My Skype
ID is kpvipin1

It's the nginx configuration; there is a regex rewrite rule to route everything through index.php; it has been near impossible to get anyone to acknowledge it.

Also have you tried php81?

Yes, it is not working in php81 also. I am also not able to load the images
or any content from public directory.
If you are comfortable, please ping me in Skype, we can work together and
debug the problem.

Hi,

Did u get any solution for php 8.2 in GAE(Flexible Environment)

Vipin,

Did you find any solution for php 8.2 Flexiblie environment

Hi vipin,

Did you find any solution for php 8.2 GAE Deployment.Still not serving static files and other php files.

Have you find any solution for that?

Hi

I didn't find any solution  for this.Waiting for Google cloud community to give solution for this problem

Did You get any Solution 

HI,

    I want to upgrade my php GAE flexible environment from php 7.3 to 8.2. I am waiting for your Solution.

Pls Kindly provide any solution for my Question.Still I didn't Find how to include JS and CSS in Php 8.2 GAE.

 Are you able to display images? If so can you share your app.yaml?

Hi,

I am not able to display(include) images also.

 

Index.php

<!doctype html>

<html>

<head>
<script src="JS/jquery-3.6.4.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href ="CSS/StyleSheet.css" />

<script>
$(document).ready(function(){
alert('inside');
})
</script>
</head>
<body>
<h1>Welcome</h1>
<img src="images/questionmark.jpg">
</body>
</html>

app.yaml
runtime: php
env: flex
service: uat

runtime_config:
operating_system: "ubuntu22"
document_root: .

indexpage.png

Hi,

Did you get any solution for php 8.2 (GAE) Flexible Environment.-(to include image, css)

Hi Google Cloud Cummunity Member,

Can you pls   give solution for this problem

I have the same problem. 

my index.php works fine in the root folder. But if i put it in any other folder it stops working. 
Can Google please respond to this. I have been scrtaching my head over this for days 

HI,

Did u get any solution for php 8.2 GAE

Hi Google Cloud Cummunity Member,

Can you please tell, how to use php 8.2 in App engine Flexible environment.We have to upgrade our application to php 8.2 ASAP. 

 

Hi,

 If I include image in PHP 8.2 GAE, Image breaking(Not showing), Same one working correclty in PHP 7.3 GAE.Like that If I Include Jquery (code.jquery.com/jquery-3.6.4.min.js),

then checked in my script means that not afftected
Help me to reslove 

Hi,

Any one get Solution for php 8.2 GAE Flexible Environment(File inclusion Not Working) problem.

In Php Info 

in Php 7.3--

$_SERVER['DOCUMENT_ROOT']/app/.

in Php 8.2-

$_SERVER['DOCUMENT_ROOT']/workspace

Pls tell how to include my image,Css and Jquery files and all in my application for php 8.2

Nothing. You?

HI ,

Did u find any other way to include JS and CSS file in our application

Hi Google Cummunity,

I am waiting for your solution for the past 2 month.We need to use PHP 8.2(GAE Flexible Environment) in Our production.production work still in Pending.Consider our issue and pls clear.

 

Hi,

If anyone get solution, pls share.

Hi Google Community Member,

I am waiting for my solution for the  past 2 month.Consider my Issue and give solution.

Just pipping in - my suspect on the issue is that it is to do with the nginx.conf ; see my post - https://www.googlecloudcommunity.com/gc/Serverless/Flexible-PHP82-nginx/m-p/620797#M1994