Skip to content

Instantly share code, notes, and snippets.

@ux-powered
Created June 23, 2020 06:02
Show Gist options
  • Save ux-powered/b3bf2da7bc038c786bd202c650827ef9 to your computer and use it in GitHub Desktop.
Save ux-powered/b3bf2da7bc038c786bd202c650827ef9 to your computer and use it in GitHub Desktop.
laravel/ui scaffolding for laravel-starter project

Prepare for scaffolding:

  1. Duplicate your package.json.
  2. Create empty resources/js/bootstrap.js, resources/sass/app.scss and resources/sass/_variables.scss files.

Installing and scaffolding:

composer require laravel/ui

php artisan ui bootstrap --auth

Type yes for both questions. Note: This will rewrite home.blade.php and HomeController.php files.


Post-scaffolding:

  1. Remove resources/js/bootstrap.js, resources/sass/app.scss and resources/sass/_variables.scss files.
  2. Remove package.json and copy the duplicated one.
  3. Run npm install and then npm run dev.
  4. Open routes/web.php and remove Route::get('/', 'HomeController')->name('home'); line.
  5. Open resources/views/layouts/application.blade.php and add <meta name="csrf-token" content="{{ csrf_token() }}"> line to the <head> block.
  6. Copy with rename resources/views/layouts/layout-blank.blade.php to resources/views/layouts/layout-auth.blade.php.
  7. Replace @extends('layouts.app') with @extends('layouts.layout-auth’) in each view within the resources/views/auth/ directory.
  8. Run DB migrations

You can find additional code examples in the resources/views/layouts/app.blade.php file.

<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Auth::routes();
Route::get('/page-2', 'Page2Controller')->name('page-2');
Route::get('/', 'HomeController@index')->name('home');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment