├── .gitignore ├── README.md ├── composer.json └── src ├── Bootstrap4Preset.php ├── Bootstrap4PresetServiceProvider.php └── bootstrap4-stubs ├── Controllers └── HomeController.php ├── _custom.scss ├── app.scss ├── bootstrap.js ├── views ├── auth │ ├── login.blade.php │ ├── passwords │ │ ├── email.blade.php │ │ └── reset.blade.php │ └── register.blade.php ├── home.blade.php ├── layouts │ └── app.blade.php └── welcome.blade.php └── webpack.mix.js /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel 5.5.x Front-end Preset For Bootstrap 4 2 | 3 | Preset for Bootstrap 4 scaffolding on new Laravel 5.5.x project. 4 | 5 | *Current version*: **Bootstrap 4 beta** 6 | 7 | ## Usage 8 | 1. Fresh install Laravel 5.5.x and `cd` to your app. 9 | 2. Install this preset via `composer require laravel-frontend-presets/bootstrap-4`. Laravel 5.5.x will automatically discover this package. No need to register the service provider. 10 | 3. Use `php artisan preset bootstrap4` for basic Bootstrap 4 preset. **OR** Use `php artisan preset bootstrap4-auth` for basic preset, Auth route entry and Bootstrap 4 Auth views in one go. (**NOTE**: If you run this command several times, be sure to clean up the duplicate Auth entries in `routes/web.php`) 11 | 4. `npm install` 12 | 5. `npm run dev` 13 | 6. Configure your favorite database (mysql, sqlite etc.) 14 | 7. `php artisan migrate` to create basic user tables. 15 | 8. `php artisan serve` (or equivalent) to run server and test preset. 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel-frontend-presets/bootstrap-4", 3 | "description": "Laravel 5.5.x Front-end preset for Bootstrap 4", 4 | "keywords": ["laravel", "preset", "bootstrap 4", "scaffolding"], 5 | "license": "MIT", 6 | "require": { 7 | "laravel/framework": "5.5.*" 8 | }, 9 | "autoload": { 10 | "psr-4": { 11 | "LaravelFrontendPresets\\Bootstrap4Preset\\": "src/" 12 | } 13 | }, 14 | "extra": { 15 | "laravel": { 16 | "providers": [ 17 | "LaravelFrontendPresets\\Bootstrap4Preset\\Bootstrap4PresetServiceProvider" 18 | ] 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Bootstrap4Preset.php: -------------------------------------------------------------------------------- 1 | '^4.0.0-beta', 45 | 'jquery' => '^3.2.1', 46 | 'tether' => '^1.4.0', 47 | 'popper.js' => '^1.12.4', 48 | 'precss' => '^2.0.0', 49 | ] + Arr::except($packages, ['foundation-sites', 'bootstrap-sass', 'bulma', 'uikit']); 50 | } 51 | 52 | /** 53 | * Update the Sass files for the application. 54 | * 55 | * @return void 56 | */ 57 | protected static function updateSass() 58 | { 59 | // clean up orphan files 60 | $orphan_sass_files = glob(resource_path('/assets/sass/*.*')); 61 | 62 | foreach($orphan_sass_files as $sass_file) 63 | { 64 | (new Filesystem)->delete($sass_file); 65 | } 66 | 67 | copy(__DIR__.'/bootstrap4-stubs/_custom.scss', resource_path('assets/sass/_custom.scss')); 68 | copy(__DIR__.'/bootstrap4-stubs/app.scss', resource_path('assets/sass/app.scss')); 69 | } 70 | 71 | /** 72 | * Update the bootstrapping files. 73 | * 74 | * @return void 75 | */ 76 | protected static function updateBootstrapping() 77 | { 78 | (new Filesystem)->delete( 79 | resource_path('assets/js/bootstrap.js') 80 | ); 81 | 82 | copy(__DIR__.'/bootstrap4-stubs/bootstrap.js', resource_path('assets/js/bootstrap.js')); 83 | } 84 | 85 | /** 86 | * Update the mix file. 87 | * 88 | * @return void 89 | */ 90 | protected static function updateMix() 91 | { 92 | (new Filesystem)->delete( 93 | base_path('webpack.mix.js') 94 | ); 95 | 96 | copy(__DIR__.'/bootstrap4-stubs/webpack.mix.js', base_path('webpack.mix.js')); 97 | } 98 | 99 | /** 100 | * Update the default welcome page file with Foundation buttons. 101 | * 102 | * @return void 103 | */ 104 | protected static function updateWelcomePage() 105 | { 106 | // remove default welcome page 107 | (new Filesystem)->delete( 108 | resource_path('views/welcome.blade.php') 109 | ); 110 | 111 | // copy new one with Bootstrap buttons 112 | copy(__DIR__.'/bootstrap4-stubs/views/welcome.blade.php', resource_path('views/welcome.blade.php')); 113 | } 114 | 115 | /** 116 | * Copy Bootstrap Auth view templates. 117 | * 118 | * @return void 119 | */ 120 | protected static function addAuthTemplates() 121 | { 122 | // Add Home controller 123 | copy(__DIR__.'/bootstrap4-stubs/Controllers/HomeController.php', app_path('Http/Controllers/HomeController.php')); 124 | 125 | // Add Auth route in 'routes/web.php' 126 | $auth_route_entry = "Auth::routes();\n\nRoute::get('/home', 'HomeController@index')->name('home');\n\n"; 127 | file_put_contents('./routes/web.php', $auth_route_entry, FILE_APPEND); 128 | 129 | // Copy Bootstrap4 Auth view templates 130 | (new Filesystem)->copyDirectory(__DIR__.'/bootstrap4-stubs/views', resource_path('views')); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/Bootstrap4PresetServiceProvider.php: -------------------------------------------------------------------------------- 1 | info('Bootstrap 4 scaffolding installed successfully.'); 19 | $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); 20 | }); 21 | 22 | PresetCommand::macro('bootstrap4-auth', function ($command) { 23 | Bootstrap4Preset::install(true); 24 | $command->info('Bootstrap 4 scaffolding with Auth views installed successfully.'); 25 | $command->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Http\Response 23 | */ 24 | public function index() 25 | { 26 | return view('home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/_custom.scss: -------------------------------------------------------------------------------- 1 | // Custom 2 | // 3 | // Override the Bootstrap defaults without modifying key, versioned files. 4 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // Fonts 3 | @import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600); 4 | 5 | // Variables 6 | @import "custom"; 7 | 8 | // Bootstrap 9 | @import "node_modules/bootstrap/scss/bootstrap"; 10 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | import Popper from 'popper.js/dist/umd/popper.js'; 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.$ = window.jQuery = require('jquery'); 12 | window.Tether = require('tether'); 13 | window.Popper = Popper; 14 | require('bootstrap'); 15 | } catch (e) {} 16 | 17 | /** 18 | * We'll load the axios HTTP library which allows us to easily issue requests 19 | * to our Laravel back-end. This library automatically handles sending the 20 | * CSRF token as a header based on the value of the "XSRF" token cookie. 21 | */ 22 | 23 | window.axios = require('axios'); 24 | 25 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 26 | 27 | /** 28 | * Next we will register the CSRF Token as a common header with Axios so that 29 | * all outgoing HTTP requests automatically have it attached. This is just 30 | * a simple convenience so we don't have to attach every token manually. 31 | */ 32 | 33 | let token = document.head.querySelector('meta[name="csrf-token"]'); 34 | 35 | if (token) { 36 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 37 | } else { 38 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 39 | } 40 | 41 | /** 42 | * Echo exposes an expressive API for subscribing to channels and listening 43 | * for events that are broadcast by Laravel. Echo and event broadcasting 44 | * allows your team to easily build robust real-time web applications. 45 | */ 46 | 47 | // import Echo from 'laravel-echo' 48 | 49 | // window.Pusher = require('pusher-js'); 50 | 51 | // window.Echo = new Echo({ 52 | // broadcaster: 'pusher', 53 | // key: 'your-pusher-key' 54 | // }); 55 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 | 5 |
6 |
7 |
8 |
9 |
10 |

Login

11 |
12 | {!! csrf_field() !!} 13 | 14 |
15 | 16 | 17 |
18 | 20 | 21 | @if ($errors->has('email')) 22 | 23 | {{ $errors->first('email') }} 24 | 25 | @endif 26 |
27 |
28 | 29 |
30 | 31 | 32 |
33 | 34 | 35 | @if ($errors->has('password')) 36 | 37 | {{ $errors->first('password') }} 38 | 39 | @endif 40 |
41 |
42 | 43 |
44 |
45 |
46 | 49 |
50 |
51 |
52 | 53 |
54 |
55 | 58 | 59 | Forgot Your 60 | Password? 61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | @endsection 70 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | 4 | @section('content') 5 |
6 |
7 |
8 |
9 |
10 |

Reset Password

11 | @if (session('status')) 12 |
13 | {{ session('status') }} 14 |
15 | @endif 16 | 17 |
18 | {!! csrf_field() !!} 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | @if ($errors->has('email')) 27 | 28 | {{ $errors->first('email') }} 29 | 30 | @endif 31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | @endsection 47 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
9 |

Reset Password

10 | 11 |
12 | {!! csrf_field() !!} 13 | 14 | 15 | 16 |
17 | 18 | 19 |
20 | 22 | 23 | @if ($errors->has('email')) 24 | 25 | {{ $errors->first('email') }} 26 | 27 | @endif 28 |
29 |
30 | 31 |
32 | 33 | 34 |
35 | 36 | 37 | @if ($errors->has('password')) 38 | 39 | {{ $errors->first('password') }} 40 | 41 | @endif 42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 | 50 | @if ($errors->has('password_confirmation')) 51 | 52 | {{ $errors->first('password_confirmation') }} 53 | 54 | @endif 55 |
56 |
57 | 58 |
59 |
60 | 63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | @endsection 71 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
9 |

Register

10 |
11 | {!! csrf_field() !!} 12 | 13 |
14 | 15 | 16 |
17 | 18 | 19 | @if ($errors->has('name')) 20 | 21 | {{ $errors->first('name') }} 22 | 23 | @endif 24 |
25 |
26 | 27 |
28 | 29 | 30 |
31 | 32 | 33 | @if ($errors->has('email')) 34 | 35 | {{ $errors->first('email') }} 36 | 37 | @endif 38 |
39 |
40 | 41 |
42 | 43 | 44 |
45 | 46 | 47 | @if ($errors->has('password')) 48 | 49 | {{ $errors->first('password') }} 50 | 51 | @endif 52 |
53 |
54 | 55 |
56 | 57 | 58 |
59 | 60 | 61 | @if ($errors->has('password_confirmation')) 62 | 63 | {{ $errors->first('password_confirmation') }} 64 | 65 | @endif 66 |
67 |
68 | 69 |
70 |
71 | 74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | @endsection 82 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 | 5 |
6 |
7 |

Dashboard

8 | 9 |

10 | You are logged in! 11 |

12 |
13 |
14 | 15 | @endsection 16 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{ config('app.name', 'Laravel') }} {{ app()->version() }} 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | {{-- top bar --}} 20 | 57 | 58 | @yield('content') 59 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Laravel {{ app()->version() }} 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 87 | 88 | 89 | 90 |
91 | @if (Route::has('login')) 92 | 100 | @endif 101 | 102 |
103 | 104 |
105 | Laravel 106 |

Version {{ app()->version() }}

107 |
108 | 109 | 116 | 117 |
118 |
119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /src/bootstrap4-stubs/webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.autoload({ 15 | jquery: ['$', 'window.jQuery', 'jQuery'], 16 | tether: ['window.Tether', 'Tether'], 17 | 'tether-shepherd': ['Shepherd'], 18 | 'popper.js/dist/popper.js': ['Popper'] 19 | }) 20 | .js('resources/assets/js/app.js', 'public/js') 21 | .sass('resources/assets/sass/app.scss', 'public/css') 22 | .options({ 23 | postCss: [ 24 | require('precss')() 25 | ] 26 | }); 27 | --------------------------------------------------------------------------------