php artisan migrate on Azure (in BitBucket pipeline)

I have setup a pipeline in BitBucket to automatically deploy my master branch of my project to an Azure Web App instance.

I have setup a pipeline in BitBucket to automatically deploy my master branch of my project to an Azure Web App instance.

The app deploys the files and runs composer update as expected (although it does warn that it's running as root), but php artisan migrate --force returns:

Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'127.0.0.1' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations)
I have already created the .env file, and when I run php artisan migrate from within a shell it runs successfully and the tables are created.

Being that 'forge' is the default user in database.php I figure .env isn't being loaded when the command is fired from the deploy script.

Is there something obvious I've missed to cause this issue, or should I somehow set it up to not run as root? I could replace the database details in database.php but I feel that's the wrong thing to do.

edit

.env contents (with certain data replaced with ********):

APP_NAME=Laravel
APP_ENV=local
APP_KEY=********
APP_DEBUG=true
APP_URL=********

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=********
DB_DATABASE=********
DB_USERNAME=********
DB_PASSWORD=********

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"


edit 2

I realise I'm yet to publish my bitbucket-pipelines.yml file:

image: php:7.2-fpm

pipelines:
  branches:
    master:
      - step:
          script:
            - apt-get update && apt-get install -qy git curl libmcrypt-dev mysql-client && apt-get install -qy unzip git
            - yes | pecl install mcrypt-1.0.1
            - docker-php-ext-install pdo_mysql
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer update
            - php artisan migrate --force
            - php artisan serve --port=80 &
            - sleep 5
            - curl -vk http://localhost:80
          deployment: staging
          services:
            - mysql

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: '******'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: '******'
        MYSQL_PASSWORD: '******'
        MYSQL_PORT: '******'

I also have a .env.pipelines file:

APP_ENV=local
APP_KEY=******
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=******
DB_USERNAME=******
DB_PASSWORD=******

Laravel Development Company | Hire Laravel Developer

Laravel Development Company | Hire Laravel Developer

Get a free quote for custom Laravel Development Services from a trusted Laravel web development company. Hire Laravel Developers now @ best affordable rates

Get a free quote for custom Laravel Development Services from a trusted Laravel web development company. Hire Laravel Developers now at best affordable rates

Laravel Tutorial - Abusing Laravel

Laravel Tutorial - Abusing Laravel

Laravel Tutorial - Abusing Laravel: In this talk, Gustavo takes a look at the importance of Unit Tests and how Dependency Injection, which is often not promoted by Laravel docs, can help to achieve Unit Testing.

In this talk, Gustavo takes a look at the importance of Unit Tests and how Dependency Injection, which is often not promoted by Laravel docs, can help to achieve Unit Testing.

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about Laravel

Laravel 5.8 Tutorial for Beginners

Learn GraphQL with Laravel and Vue.js - Full Tutorial

Export or Import of CSV or Excel file in Laravel 5.8 with MySQL

Laravel 5.8 CRUD Tutorial With Example Step By Step

Build RESTful API In Laravel 5.8 Example

Laravel 6 Tutorial - How to make Auth in Laravel 6

Laravel 6 Tutorial - How to make Auth in Laravel 6

Are you looking for make Auth in Laravel 6 then I will help you to make Authentication using Laravel UI package in Laravel 6. I will explain to you how to create login and registration using Auth in Laravel 6.

Originally published at https://itsolutionstuff.com

Laravel 6 provide septate composer package for creating Auth scaffold in Laravel 6 application. Whenever you require to create auth in Laravel 6 then you must have to install Laravel/ui package in Laravel 6.

Using Laravel/ui you can create simple view with Auth as same you did before you do. But you have to use Vue.js or React.js with Auth view in Laravel 6. But they does not provide as default you have to follow few step to do Auth.

You have to follow few step to make auth in your Laravel 6 application.

First you need to install laravel/ui package as like bellow:

composer require laravel/ui

After that you can run following command and check ui commands info.

php artisan ui --help

Output:

Description:
  Swap the front-end scaffolding for the application
Usage:
  ui [options] [--] 
Arguments:
  type                   The preset type (bootstrap, vue, react)
Options:
      --auth             Install authentication UI scaffolding
      --option[=OPTION]  Pass an option to the preset command (multiple values allowed)
  -h, --help             Display this help message
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi             Force ANSI output
      --no-ansi          Disable ANSI output
  -n, --no-interaction   Do not ask any interactive question
      --env[=ENV]        The environment the command should run under
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

You can use following commands for creating auth:

Using Vue:

php artisan ui vue --auth

Using React:

php artisan ui react --auth

Now you need to run npm command, otherwise you can not see better layout of login and register page.

Install NPM:

npm install

Run NPM:

npm run dev

Now you can run and check your app.

It will work great.

I hope it can help you....

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow me on Facebook | Twitter

Further reading

Laravel 5.8 Tutorial for Beginners

What’s New in Laravel 6.0

Laravel 6 CRUD Application Tutorial

Laravel 6 Image Upload Tutorial