Laravel 7 on Debian buster

AJA • May 12, 2020

laravel debian

Debian is a free operating system (OS) for your computer. An operating system is the set of basic programs and utilities that make your computer run.

Laravel is a web application framework.

Tailwind CSS is a customizable, low-level CSS framework.

Install Debian according to this post.

Composer

Use composer to install laravel7 project.

cd /var/www/html
sudo -u www-data composer create-project --prefer-dist laravel/laravel laravel7

Database

Create a mysql database laravel7 with Phpmyadmin.

Change database mysql parameters in /var/www/html/laravel7/.env file.

cd laravel7
sudo -u www-data nano .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel7
DB_USERNAME=root
DB_PASSWORD=password

Laravel ui, run npm and migrate

sudo -u www-data composer require laravel/ui
sudo -u www-data php artisan ui vue --auth
sudo -u www-data npm install
sudo -u www-data npm run dev
sudo -u www-data php artisan migrate

Tailwind

sudo -u www-data npm install tailwindcss

Edit app.scss

sudo -u www-data nano resources/sass/app.scss

Change resources/sass/app.scss with :

@tailwind base;
@tailwind components;
@tailwind utilities;

Generate the tailwind.config.js.

sudo -u www-data npx tailwind init

Edit webpack.mix.js to include Tailwind in Laravel Mix Build Process.

sudo -u www-data nano webpack.mix.js
const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')

const tailwindcss = require('tailwindcss')

mix.sass('resources/sass/app.scss', 'public/css')
   .options({
      processCssUrls: false,
      postCss: [ tailwindcss('tailwind.config.js') ],
})

Run npm again.

sudo -u www-data npm install
sudo -u www-data npm run dev

Change views from laravel-frontend-presets.

npm rebuild