Skip to content

Instantly share code, notes, and snippets.

@attacomsian
Forked from ffmit/Laravel.md
Created November 16, 2020 09:12
Show Gist options
  • Save attacomsian/d7a6a3c97cce8233bd19faeb9c1dd9b7 to your computer and use it in GitHub Desktop.
Save attacomsian/d7a6a3c97cce8233bd19faeb9c1dd9b7 to your computer and use it in GitHub Desktop.
Laravel - Frequently used commands

Laravel - Standard tasks for a new project

Mac: Prerequisites

Mac: Node / Install or update

Mac: Update Node

Mac: n needs to be installed

npm install -g n

Mac: Then update Node.js to latest version using n

sudo n latest

Mac: Update NPM

npm cache clean -f sudo npm install -g npm

Windows: NPM / Install or update

Windows: Install NPM

tbd

Windows: Update NPM

npm install -g npm

Laravel preparation

Check current Laravel version

php artisan --version

Check for update or install new

composer global require laravel/installer

Create project in existing directory

composer create-project laravel/laravel .

Create project the standard way

laravel new appname --jet

Add self-diagnosis

composer require beyondcode/laravel-self-diagnosis

Run self-diagnosis

php artisan self-diagnosis

Laravel - Basic config

Create application key

php artisan key:generate

NPM preparation

Prepare

Fontawesome

Either install version 4.7

  1. npm install font-awesome --save

OR

Install version 5.x

  1. npm install @fortawesome/fontawesome-free --save

Optional: Bootstrap

  1. npm install tether --save
  2. npm install popper.js --save
  3. npm install bootstrap --save

Reference for NPM build process

  1. Open "/webpack.mix.js"

Add

mix
    .sass('resources/sass/app.scss','public/css/app.css').version()
    .js([
        'resources/js/app.js',
        './node_modules/jquery/dist/jquery.js',
        './node_modules/bootstrap/dist/js/bootstrap.js',
        ],'public/js/app.js').version();
  1. Open "/resources/sass/app.scss"

Add

// Fonts
@import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);

// Bulma dependencies
@import "~bulma";
@import "~bulma-badge";
@import '~bulma-calendar';

// Font-Awesome 4.70
//$fa-font-path: "~font-awesome/fonts";
//@import "~font-awesome";


// Font-Awesome 5.x basic
@import "~@fortawesome/fontawesome-free";

// Font-Awesome 5.x fonts
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts";
@import "~@fortawesome/fontawesome-free/scss/fontawesome.scss";
@import "~@fortawesome/fontawesome-free/scss/solid.scss";
@import "~@fortawesome/fontawesome-free/scss/regular.scss";
@import "~@fortawesome/fontawesome-free/scss/brands.scss";

Build!

  1. npm run dev

Composer

Global

  1. composer global require friendsofphp/php-cs-fixer
  2. composer global require phpmd/phpmd

Project

  1. composer require rap2hpoutre/laravel-log-viewer

Bulma Auth Preset

Add with composer

  1. composer require laravel-frontend-presets/bulma

Install

  1. php artisan preset bulma-auth && npm install && npm run dev

API-only approach

Passport

Install Passport

  1. composer require laravel/passport && php artisan migrate && php artisan passport:install

Configure Passport

Modify User model:

use Laravel\Passport\HasApiTokens; class User extends Authenticatable { use HasApiTokens, Notifiable; }

Vue

composer require laravel/ui --dev && php artisan ui vue && npm install && npm run dev && php artisan ui vue --auth && npm install && npm run dev && php artisan migrate

Replace Bootstrap CSS with Bulma CSS

composer require laravel-frontend-presets/bulma && php artisan preset bulma-auth && npm install && npm run dev

Standard routes

Web

Authentication resources

Auth::routes();

Log route

Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');

Resourceful route / API

Route::resource('photos', 'PhotoController');

Artisan route:list

List all routes for a given resource

php artisan route:list --name items

API

Production

Every deployment

Clear caches

php artisan route:clear

php artisan config:clear

php artisan view:clear

Build

npm run prod

php artisan route:cache

Passport

php artisan passport:keys

Vue

You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html

#phpcs

Comments for files

Ignore file completely

{{--// phpcs:ignoreFile--}}

Artisan

Serve to LAN

php artisan serve --host=<your_machine_ip> --port=8000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment