Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Laravel on Cloud Run #1680

Merged
merged 39 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d3ea481
Laravel on Cloud Run -- initial code
glasnt Jul 27, 2022
f7f1c3c
Add procfile with re-routed log files to Cloud Run visible places
glasnt Aug 5, 2022
300df47
Create README.md
glasnt Aug 29, 2022
e7fb062
Fix formatting
glasnt Aug 29, 2022
d43b0eb
Show demo outcome
glasnt Aug 29, 2022
17488fa
php-cs-fixer
glasnt Aug 29, 2022
f4ba7e5
Resize/rescale demo screenshot
glasnt Aug 29, 2022
34d1c4f
Update README.md
glasnt Aug 29, 2022
a3775db
Update README.md for launch
glasnt Aug 29, 2022
1c8be7b
Merge branch 'master' into laravel
glasnt Aug 29, 2022
3e18156
php-cs-fixer w/.php-cs-fixer.dist.php config
glasnt Aug 29, 2022
11c8056
Merge branch 'laravel' of github.com:glasnt/php-docs-samples into lar…
glasnt Aug 29, 2022
09c539a
Apply php-cs-fix to all files in config, outside my demo
glasnt Aug 29, 2022
0e36cb5
Update run/laravel/app/Providers/RouteServiceProvider.php
glasnt Sep 12, 2022
84b934b
Merge branch 'master' into laravel
glasnt Sep 12, 2022
07af9e2
Merge branch 'master' into laravel
glasnt Oct 4, 2022
8c8da02
Merge branch 'master' into laravel
glasnt Nov 4, 2022
9bd19f3
Merge branch 'master' into laravel
glasnt Nov 29, 2022
9c0f499
Update dependencies
glasnt Dec 1, 2022
7b3c3ef
Merge branch 'main' into laravel
glasnt Dec 1, 2022
4842971
Merge branch 'main' into laravel
glasnt Dec 11, 2022
b788437
Revert "Apply php-cs-fix to all files in config, outside my demo"
glasnt Dec 11, 2022
9e41a88
Merge branch 'laravel' of github.com:glasnt/php-docs-samples into lar…
glasnt Dec 11, 2022
aab5810
Move PROJECTNUM
glasnt Dec 11, 2022
065ed58
Update REGION, clarify update steps
glasnt Dec 11, 2022
8e39de8
update minimum PHP (pending changes in comments)
glasnt Dec 11, 2022
d8c9e4f
Move tests to test/ (might fix kokoro?)
glasnt Dec 11, 2022
875159a
Reorder template envs
glasnt Dec 11, 2022
d6d02a4
Make registry name an envvar
glasnt Dec 11, 2022
96eae35
Unpin expected version output
glasnt Dec 11, 2022
e24ab87
Update run/laravel/routes/web.php
glasnt Dec 11, 2022
36549f4
Update asset bucket/url notes
glasnt Dec 11, 2022
c8c47b6
Merge branch 'laravel' of github.com:glasnt/php-docs-samples into lar…
glasnt Dec 11, 2022
cbb857c
remove unused app/helpers.php, update docs to suit
glasnt Dec 12, 2022
ab14be7
Update reasoning for local installations
glasnt Dec 12, 2022
ac9f702
Merge branch 'main' into laravel
glasnt Dec 12, 2022
5c8e22b
Update run/laravel/README.md
bshaffer Dec 12, 2022
62aca7d
Merge branch 'main' into laravel
glasnt Dec 12, 2022
87f466e
Merge branch 'main' into laravel
glasnt Dec 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compute/api-client/helloworld/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function generateMarkup($apiRequestName, $apiResponse)
} else {
print "<a class='logout' href='?logout'>Logout</a>";
}
?>
?>
glasnt marked this conversation as resolved.
Show resolved Hide resolved
</div>
</body>
</html>
42 changes: 21 additions & 21 deletions functions/http_content_type/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ function helloContent(ServerRequestInterface $request): string
switch ($request->getHeaderLine('content-type')) {
// '{"name":"John"}'
case 'application/json':
if (!empty($body)) {
$json = json_decode($body, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new RuntimeException(sprintf(
'Could not parse body: %s',
json_last_error_msg()
));
}
$name = $json['name'] ?? $name;
}
break;
// 'John', stored in a stream
if (!empty($body)) {
$json = json_decode($body, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new RuntimeException(sprintf(
'Could not parse body: %s',
json_last_error_msg()
));
}
$name = $json['name'] ?? $name;
}
break;
// 'John', stored in a stream
case 'application/octet-stream':
$name = $body;
break;
// 'John'
$name = $body;
break;
// 'John'
case 'text/plain':
$name = $body;
break;
// 'name=John' in the body of a POST request (not the URL)
$name = $body;
break;
// 'name=John' in the body of a POST request (not the URL)
case 'application/x-www-form-urlencoded':
parse_str($body, $data);
$name = $data['name'] ?? $name;
break;
parse_str($body, $data);
$name = $data['name'] ?? $name;
break;
glasnt marked this conversation as resolved.
Show resolved Hide resolved
}

return sprintf('Hello %s!', htmlspecialchars($name));
Expand Down
3 changes: 3 additions & 0 deletions run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
| Sample | Description | Deploy |
| --------------------------------------- | ------------------------ | ------------- |
|[Hello World][helloworld] | Quickstart | [<img src="https://storage.googleapis.com/cloudrun/button.svg" alt="Run on Google Cloud" height="30"/>][run_button_helloworld] |
|[Laravel][laravel] | Deploy Laravel on Cloud Run | -|


For more Cloud Run samples beyond PHP, see the main list in the [Cloud Run Samples repository](https://github.com/GoogleCloudPlatform/cloud-run-samples).

Expand Down Expand Up @@ -87,4 +89,5 @@ for more information.
[run_build]: https://cloud.google.com/run/docs/building/containers
[run_deploy]: https://cloud.google.com/run/docs/deploying
[helloworld]: helloworld/
[laravel]: laravel/
[run_button_helloworld]: https://deploy.cloud.run/?dir=run/helloworld
22 changes: 22 additions & 0 deletions run/laravel/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
APP_NAME=MyApp
APP_ENV=local

# this value will be generated
APP_KEY=


# Logging
LOG_CHANNEL=syslog
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

# Database
DB_CONNECTION=mysql
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_SOCKET=/cloudsql/PROJECT_ID:REGION:INSTANCE

# Static
ASSET_BUCKET=BUCKET_NAME
ASSET_URL=https://storage.googleapis.com/${ASSET_BUCKET}
2 changes: 2 additions & 0 deletions run/laravel/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!include:.gitignore
.git
16 changes: 16 additions & 0 deletions run/laravel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.idea
/.vscode
3 changes: 3 additions & 0 deletions run/laravel/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web: pid1 --nginxBinaryPath nginx --nginxConfigPath /layers/google.php.webconfig/webconfig/nginx.conf --serverConfigPath /layers/google.php.webconfig/webconfig/nginxserver.conf --nginxErrLogFilePath /var/log/nginx.log --customAppCmd "php-fpm -R --nodaemonize --fpm-config /layers/google.php.webconfig/webconfig/php-fpm.conf" --pid1LogFilePath /var/log/pid1.log --mimeTypesPath /layers/google.utils.nginx/nginx/conf/mime.types --customAppSocket /layers/google.php.webconfig/webconfig/app.sock
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirmed this setup vs the current buildpack web config, and it's still 'up to date', and the logs end up in Cloud Run successfully.

migrate: php artisan migrate
static: npm run update-static
Loading