Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

Deploy Laravel on Google App Engine – Standard

by Cloudbooklet
5 years ago
in Google Cloud, App Engine
Deploy Laravel On Google App Engine - Standard
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Deploy Laravel on Google App Engine – Standard and connect with Google Cloud SQL with Cloud SQL Proxy. This guide demonstrates how to set up deploy your first Laravel app in App Engine Standard Environment with Cloud SQL. Not using App Engine? Choose a different Category: ADVERTISEMENT Compute Engine You might also like How to […]

ADVERTISEMENT

Deploy Laravel on Google App Engine – Standard and connect with Google Cloud SQL with Cloud SQL Proxy.

This guide demonstrates how to set up deploy your first Laravel app in App Engine Standard Environment with Cloud SQL.

Not using App Engine? Choose a different Category:

ADVERTISEMENT

Compute Engine

App Engine – Std

App Engine – Flex

ADVERTISEMENT

Prerequisites

  1. Create a project in the Google Cloud Platform Console.
  2. Enable billing for your project.
  3. Install and initialize the Google Cloud SDK.
  4. Create a Cloud SQL Second Generation Instance.
  5. Composer installed on your local computer.

Local Laravel Set Up

Create a directory in your local computer and install the Laravel installer.

You might also like

How To Setup Ssh Keys On Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

4 months ago
Draggan Ai Editing Tool Install And Use Draggan Photo Editor

DragGAN AI Editing Tool Install and Use DragGAN Photo Editor

4 months ago
mkdir my-project
composer global require laravel/installer

Create a new Laravel application using the laravel new command.

ADVERTISEMENT
cd my-project
laravel new my-app

Now Laravel will be installed inside the my-app directory.

You can verify the installation with the following command.

ADVERTISEMENT
cd my-app
php artisan serve

Visit http://localhost:8000 on your web browser to see the Laravel Welcome page.

Set up Laravel for App Engine

01. Generate application key with the following command.

ADVERTISEMENT
php artisan key:generate --show

02. Create an app.yaml file with the following contents:

Replace YOUR_APP_KEY with the application key you have generated in the above step.

runtime: php72
env_variables:
APP_KEY: YOUR_APP_KEY
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp

03. Set the storage path to /tmp for caching in production.

Edit the bootstrap/app.php and add the below code before the return statement.

$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));

So your app.php will look like this.

$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

04. Now remove the laravel-dump-server repository to prevent the Laravel’s caching error.

composer remove --dev beyondcode/laravel-dump-server

Now your application is ready to be deployed to App Engine.

Enable APIs and Create New Service account

Go to APIs and Services and click Enable APIs and Services and enable Cloud SQL API and Cloud SQL Admin API

Go to IAM & Admin >> Service accounts and click Create service account

In step 1

Enter Service account Name

Click Create

In step 2

Select Role

Cloud SQL >> Cloud SQL Client
Project >> Editor

Click Continue

In step 3

Click Create Key

Choose Key type as JSON

Click Create

Install Cloud SQL Proxy in Local Machine

Follow the instructions to install the Cloud SQL proxy client on your local machine. The Cloud SQL proxy is used to connect to your Cloud SQL instance when running locally.

Start the Cloud SQL proxy and replace CLOUDSQL_CONNECTION_NAME with the connection name of your Cloud SQL Instance.

You can get the connection name from your Cloud SQL Dashboard.

Cloud Sql Connection Name
./cloud_sql_proxy -instances=CLOUDSQL_CONNECTION_NAME=tcp:3306

If you are using windows machine you need to update the ./cloud_sql_proxy with the path of the downloaded proxy.

Run Migrations for Laravel

Once the Proxy is started you will something similar to this.

2019/03/06 15:48:17 Listening on 127.0.0.1:3306 for CLOUDSQL_CONNECTION_NAME
2019/03/06 15:48:17 Ready for new connections

Now edit your .env file and update the database details.

DB_DATABASE=CLOUD_SQL_DATABASE_NAME
DB_USERNAME=CLOUD_SQL_USERNAME
DB_PASSWORD=CLOUD_SQL_PASSWORD

Important: Open a new command prompt and navigate to your Laravel’s root directory and run the database migrations for Laravel.

php artisan session:table
php artisan migrate --force

If the migrations are completed successfully, you will see the output similar to the one below.

Output
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrating: 2019_03_06_101455_create_sessions_table
Migrated: 2019_03_06_101455_create_sessions_table

Great! Now you can deploy your Laravel application to App Engine.

Deploy Laravel to App Engine

Edit your app.yaml and update the Cloud SQL details.

runtime: php72

env_variables:
APP_KEY: YOUR_APP_KEY
APP_STORAGE: /tmp
CACHE_DRIVER: database
SESSION_DRIVER: database
DB_DATABASE: CLOUD_SQL_DATABASE_NAME
DB_USERNAME: CLOUD_SQL_USERNAME
DB_PASSWORD: CLOUD_SQL_PASSWORD
DB_SOCKET: "/cloudsql/CLOUDSQL_CONNECTION_NAME"

Once done, run the below command to deploy the app on App Engine.

gcloud app deploy

Once the deployment is completed check this url (http://YOUR_PROJECT_ID.appspot.com) to see the Laravel Welcome page.

Laravel Welcome Page

Conclusion

Now you have learned how to deploy your Laravel application on Google App Engine – Standard Environment.

Thanks for your time. If you face any problem or any feedback, just leave a comment below.

Tags: Google Cloud PlatformLaravel
ShareTweetSendShare
Cloudbooklet

Cloudbooklet

Comments 4

  1. Avatar Of Same Issues same issues says:
    4 years ago

    getting PHP Notice: Symfony\Component\Debug\Exception\FatalThrowableError: Class ‘Facade\Ignition\IgnitionServiceProvider’ not found in /srv/vendor/laravel/framework/s

    and
    “Please provide a valid cache path.”

    Reply
  2. Avatar Of Hicham Hicham says:
    4 years ago

    I followed all the steps in this article but after deployment I keep getting this error “Please provide a valid cache path.”

    Reply
    • Avatar Of Cloudbooklet Cloudbooklet says:
      4 years ago

      Did you follow the point 4 to remove the caching in bootstrap/cache/services.php

      Reply
      • Avatar Of Fairuz Wan Ismail Fairuz Wan Ismail says:
        3 years ago

        can you pinpoint how to remove the caching in said file? I cannot find the point 4

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

7 months ago
How To Install Or Upgrade Php 8.2 On Ubuntu 22.04

How to Install or Upgrade PHP 8.2 on Ubuntu 22.04

9 months ago
How To Change Timezone On Ubuntu 22.04

How to Change Timezone on Ubuntu 22.04

1 year ago
How To Install Ansible On Ubuntu 22.04

How to Install Ansible on Ubuntu 22.04

1 year ago

Follow Us

Trending Articles

Chatgpt For Marketing

Top 10 Ways to Use ChatGPT for Marketing in 2023

September 22, 2023

Why Did Meta Shut Down 3 VR Games?

Interactive AI – Next Phase of Artificial Intelligence

Validator AI: The AI Powered Business Idea Validator

AI Powered 3D Models to Create 3D Designs in Breeze

AI Statistics and Trends: What You Need to Know in 2023

Popular Articles

Who Unfollowed You On Instagram

How to Find Who Unfollowed You on Instagram

September 11, 2023

How to Make Money with AI: A Step-by-Step Guide

5 Best TikTok Private Account Viewer in 2023

Charley AI: The Best AI Essay Writing Tool

4 Ways to Reset Snapchat Password

How to Use WhatsApp Pi – Personal AI Assistant for WhatsApp

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.