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|430x202](upload://4rl4HYnQsa1JiKZrdTrbWXsWreo.png)

Am waiting for your valuable response.

2 Likes

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!

1 Like

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.

1 Like

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)

1 Like
document_root: public

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

1 Like

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

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>
1 Like

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.

1 Like

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

1 Like

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

1 Like

Have you find any solution for that?

1 Like

Hi

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

1 Like

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.

2 Likes

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

1 Like

Also have you tried php81?

1 Like

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: .

1 Like

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.

1 Like

Hi Google Cloud Cummunity Member,

Can you pls give solution for this problem

1 Like

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

1 Like

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.

1 Like

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.

1 Like