I am new to both Google Cloud Storage and Google Analytics API v4.
I have created a helloworld application where I add JS and CSS files. I have uploaded the same in the google storage. But JS and CSS files are not working.
This is what I have done so far.
- I have created a new project.
- I have generate a new service and keep the downloaded JSON file in the root of the project.
- I have created a storage bucket.
- I am using default app engine.
I am using GCConsole to upload the project. While uploading I am using old settings with new properties. At the end when I give command gcloud app console, in the service list, I do not found and I do not asked by the console to mention the storage bucket. I have add the bucket in my PHP file. Below I have shared my files.
Questions
- I have created storage bucket, service JSON file. I am using default app engine. Is there anything I am missing?
- Is it possible to upload the project in VM Instance and test?
- What is the difference between VM Instance and App Engine?
- How do I create and test proper app.yaml file?
- Is it mandatory to use and configure bucket in PHP code? Is there any alternatives?
- I do not found the project under the bucket I have created. I found it in App Engine > Source. In the bucket there are 3 different folders are created automatically. Is this approach correct?
- Is it possible to update the project URL with user friendly URL?
- How can I run Google Reports API v4 scripts (PHP, Java) in Google Storage?
- Why JS and CSS files are not working?
Project's Folder Structure
\root\
\vendor\
\css\style.css
\js\main.js
index.php
app.yaml
abcde-9c0e6b4e4b6c.json
composer.json
composer.lock
README.md
index.php
<?php
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
use google\appengine\api\cloud_storage\CloudStorageTools;
$projectId = 'projid';
$bucketId = 'buckid';
$storage = new StorageClient([
'projectId' => $projectId,
'keyFilePath' => 'abcde-9c0e6b4e4b6c.json',
]);
$gcsBucket = $storage->bucket($bucketId);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<title>GCP PHP</title>
</head>
<body>
<h1>Welcome to GCP World</h1>
<div class="p1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis nihil molestias mollitia iste aliquam placeat quis nobis nesciunt, pariatur ipsa eligendi eveniet ipsam voluptatibus, voluptate eaque alias velit voluptatem id enim sed quisquam praesentium necessitatibus sint. Distinctio nam deleniti, a, eos reprehenderit eligendi, officiis nisi adipisci nostrum et delectus earum.</div>
<div class="p2">Iure, rerum, inventore! Nulla nesciunt autem, facere eius quas, a ipsum necessitatibus adipisci, reprehenderit eaque fugit debitis dicta voluptates dignissimos quos? Tenetur deleniti impedit excepturi dolorem voluptas, quidem animi ullam! Deserunt eum, modi, eligendi et quam, magni sapiente dolorem porro eaque quibusdam nihil ratione consequuntur amet autem voluptas suscipit, molestiae!</div>
<div class="p3">Molestias architecto a expedita nostrum, ullam sapiente quia temporibus nesciunt aperiam, asperiores dolor tempore, delectus ipsam sunt? Consequuntur facere reprehenderit nemo voluptatibus ad facilis nostrum temporibus perferendis sequi quasi voluptas, voluptatum repellendus rerum quas repudiandae quidem ipsam eligendi ex numquam sint culpa itaque eum? A saepe deserunt ea asperiores fugiat.</div>
<div class="footer1"></div>
<script src="js/main.js"></script>
</body>
</html>
app.yaml
runtime: php73
handlers:
- url: /.*
script: auto
runtime_config:
document_root: .