├── _config.yml ├── src ├── Commands │ ├── Presets │ │ ├── element-stubs │ │ │ ├── app.scss │ │ │ ├── app.js │ │ │ ├── App.vue │ │ │ ├── webpack.mix.js │ │ │ ├── _variables.scss │ │ │ ├── bootstrap.js │ │ │ └── ExampleComponent.vue │ │ ├── Bootstrap.php │ │ ├── React.php │ │ ├── None.php │ │ ├── Vue.php │ │ └── Element.php │ ├── README.md │ └── PresetCommand.php └── PresetServiceProvider.php ├── composer.json ├── LICENSE └── README.md /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/app.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | @import 'variables'; 3 | 4 | -------------------------------------------------------------------------------- /src/Commands/README.md: -------------------------------------------------------------------------------- 1 | # Preset Commands 2 | 3 | All the preset commands are located in this folder 4 | -------------------------------------------------------------------------------- /src/PresetServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 17 | $this->commands([ 18 | \Maogou\Preset\Commands\PresetCommand::class 19 | ] ); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | /** 11 | * Next, we will create a fresh Vue application instance and attach it to 12 | * the page. Then, you may begin adding components to this application 13 | * or customize the JavaScript scaffolding to fit your unique needs. 14 | */ 15 | 16 | import App from './App.vue'; 17 | import ElementUI from 'element-ui'; 18 | import 'element-ui/lib/theme-chalk/index.css'; 19 | 20 | Vue.use(ElementUI); 21 | 22 | const app = new Vue({ 23 | el: '#app', 24 | render: h => h(App), 25 | }); 26 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/App.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click to open me 5 | 6 | You Should Try Element (This is in /resources/js/App.vue) 7 | 8 | 9 | 10 | 24 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | 4 | mix.webpackConfig({ 5 | module: { 6 | rules: [ 7 | { 8 | test: /\.css$/, 9 | loader: "style-loader!css-loader" 10 | }, 11 | ] 12 | } 13 | }); 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Mix Asset Management 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Mix provides a clean, fluent API for defining some Webpack build steps 21 | | for your Laravel application. By default, we are compiling the Sass 22 | | file for the application as well as bundling up all the JS files. 23 | | 24 | */ 25 | 26 | mix.js('resources/js/app.js', 'public/js') 27 | .sass('resources/sass/app.scss', 'public/css'); 28 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maogou/preset", 3 | "description": "Laravel front end preset package", 4 | "keywords": [ 5 | "vue", 6 | "laravel", 7 | "element-ui", 8 | "bootstrap", 9 | "react", 10 | "laravel-preset" 11 | ], 12 | "license": "MIT", 13 | "type": "library", 14 | "require": { 15 | "php": "^7.1.3" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "^7.5", 19 | "orchestra/testbench": "^3.8", 20 | "laravel/framework": "5.8.*" 21 | }, 22 | "author": { 23 | "name": "maogou", 24 | "email": "kinyou_xy@126.com" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "Maogou\\Preset\\": "src/" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "Maogou\\Preset\\Tests\\": "tests/" 34 | } 35 | }, 36 | "extra": { 37 | "laravel": { 38 | "providers": [ 39 | "Maogou\\Preset\\PresetServiceProvider" 40 | ] 41 | } 42 | }, 43 | "minimum-stability": "dev" 44 | } 45 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/_variables.scss: -------------------------------------------------------------------------------- 1 | // Body 2 | $body-bg: #f5f8fa; 3 | 4 | // Borders 5 | $laravel-border-color: darken($body-bg, 10%); 6 | $list-group-border: $laravel-border-color; 7 | $navbar-default-border: $laravel-border-color; 8 | $panel-default-border: $laravel-border-color; 9 | $panel-inner-border: $laravel-border-color; 10 | 11 | // Brands 12 | $brand-primary: #3097D1; 13 | $brand-info: #8eb4cb; 14 | $brand-success: #2ab27b; 15 | $brand-warning: #cbb956; 16 | $brand-danger: #bf5329; 17 | 18 | // Typography 19 | $font-family-sans-serif: "Raleway", sans-serif; 20 | $font-size-base: 14px; 21 | $line-height-base: 1.6; 22 | $text-color: #636b6f; 23 | 24 | // Navbar 25 | $navbar-default-bg: #fff; 26 | 27 | // Buttons 28 | $btn-default-color: $text-color; 29 | 30 | // Inputs 31 | $input-border: lighten($text-color, 40%); 32 | $input-border-focus: lighten($brand-primary, 25%); 33 | $input-color-placeholder: lighten($text-color, 30%); 34 | 35 | // Panels 36 | $panel-default-heading-bg: #fff; -------------------------------------------------------------------------------- /src/Commands/Presets/Bootstrap.php: -------------------------------------------------------------------------------- 1 | "^0.18" , 20 | "bootstrap" => "^4.0.0" , 21 | "cross-env" => "^5.1" , 22 | "jquery" => "^3.2" , 23 | "laravel-mix" => "^4.0.7" , 24 | "lodash" => "^4.17.5" , 25 | "popper.js" => "^1.12" , 26 | "resolve-url-loader" => "^2.3.1" , 27 | "sass" => "^1.15.2" , 28 | "sass-loader" => "^7.1.0" , 29 | "vue" => "^2.5.17" 30 | ] + $packages; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Commands/Presets/React.php: -------------------------------------------------------------------------------- 1 | "^7.0.0" , 21 | "axios" => "^0.18" , 22 | "bootstrap" => "^4.0.0" , 23 | "cross-env" => "^5.1" , 24 | "jquery" => "^3.2" , 25 | "laravel-mix" => "^4.0.7" , 26 | "lodash" => "^4.17.5" , 27 | "popper.js" => "^1.12" , 28 | "react" => "^16.2.0" , 29 | "react-dom" => "^16.2.0" , 30 | "resolve-url-loader" => "^2.3.1" , 31 | "sass" => "^1.15.2" , 32 | "sass-loader" => "^7.1.0" 33 | ] + Arr::except($packages, ['vue']); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 maogou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [](https://travis-ci.org/maogou/swappreset) 5 | [](https://packagist.org/packages/maogou/preset) 6 | [](https://packagist.org/packages/maogou/preset) 7 | [](https://packagist.org/packages/maogou/preset) 8 | 9 | ## Installation 10 | 11 | ```sh 12 | $ composer require maogou/preset -vvv 13 | ``` 14 | 15 | ## Swap Preset 16 | 17 | ```sh 18 | $ php artisan swap:preset vue 19 | $ php artisan swap:preset none 20 | $ php artisan swap:preset react 21 | $ php artisan swap:preset element 22 | $ php artisan swap:preset bootstrap 23 | ``` 24 | 25 | ### Laravel version Compatibility 26 | 27 | Laravel | Package 28 | :---------|:---------- 29 | 5.8.x | 1.0.x 30 | 31 | 32 | 33 | ## License 34 | 35 | Laravel preset is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 36 | -------------------------------------------------------------------------------- /src/Commands/Presets/None.php: -------------------------------------------------------------------------------- 1 | "^0.18" , 21 | "cross-env" => "^5.1" , 22 | "laravel-mix" => "^4.0.7" , 23 | "lodash" => "^4.17.5" , 24 | "resolve-url-loader" => "^2.3.1" , 25 | "sass" => "^1.15.2" , 26 | "sass-loader" => "^7.1.0" 27 | ] + Arr::except( 28 | $packages , [ 29 | '@babel/preset-react' , 30 | 'react' , 31 | 'react-dom', 32 | 'vue', 33 | 'popper.js', 34 | 'jquery', 35 | 'bootstrap' 36 | ] 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Commands/Presets/Vue.php: -------------------------------------------------------------------------------- 1 | "^0.18" , 21 | "bootstrap" => "^4.0.0" , 22 | "cross-env" => "^5.1" , 23 | "jquery" => "^3.2" , 24 | "laravel-mix" => "^4.0.7" , 25 | "lodash" => "^4.17.5" , 26 | "popper.js" => "^1.12" , 27 | "resolve-url-loader" => "^2.3.1" , 28 | "sass" => "^1.15.2" , 29 | "sass-loader" => "^7.1.0" , 30 | "vue" => "^2.5.17" 31 | ] + Arr::except( 32 | $packages , [ 33 | '@babel/preset-react', 34 | 'react', 35 | 'react-dom', 36 | ] 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 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 | window.$ = window.jQuery = require('jquery'); 11 | 12 | /** 13 | * Vue is a modern JavaScript library for building interactive web interfaces 14 | * using reactive data binding and reusable components. Vue's API is clean 15 | * and simple, leaving you to focus on building your next great project. 16 | */ 17 | 18 | window.Vue = require('vue'); 19 | 20 | /** 21 | * We'll load the axios HTTP library which allows us to easily issue requests 22 | * to our Laravel back-end. This library automatically handles sending the 23 | * CSRF token as a header based on the value of the "XSRF" token cookie. 24 | */ 25 | 26 | window.axios = require('axios'); 27 | 28 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 29 | 30 | /** 31 | * Next we will register the CSRF Token as a common header with Axios so that 32 | * all outgoing HTTP requests automatically have it attached. This is just 33 | * a simple convenience so we don't have to attach every token manually. 34 | */ 35 | 36 | let token = document.head.querySelector('meta[name="csrf-token"]'); 37 | 38 | if (token) { 39 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 40 | } else { 41 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 42 | } 43 | 44 | /** 45 | * Echo exposes an expressive API for subscribing to channels and listening 46 | * for events that are broadcast by Laravel. Echo and event broadcasting 47 | * allows your team to easily build robust real-time web applications. 48 | */ 49 | 50 | // import Echo from 'laravel-echo' 51 | 52 | // window.Pusher = require('pusher-js'); 53 | 54 | // window.Echo = new Echo({ 55 | // broadcaster: 'pusher', 56 | // key: process.env.MIX_PUSHER_APP_KEY, 57 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 58 | // encrypted: true 59 | // }); 60 | -------------------------------------------------------------------------------- /src/Commands/PresetCommand.php: -------------------------------------------------------------------------------- 1 | argument('type'))) { 36 | return call_user_func(static::$macros[$this->argument('type')], $this); 37 | } 38 | 39 | if (! in_array($this->argument('type'), ['none','bootstrap','vue','react','element'])) { 40 | throw new InvalidArgumentException('Invalid preset.'); 41 | } 42 | 43 | return $this->{$this->argument('type')}(); 44 | } 45 | 46 | /** 47 | * Install the "fresh" preset. 48 | * 49 | * @return void 50 | */ 51 | protected function none() 52 | { 53 | $this->call('preset',['type'=>'none']); 54 | } 55 | 56 | /** 57 | * Install the "bootstrap" preset. 58 | * 59 | * @return void 60 | */ 61 | protected function bootstrap() 62 | { 63 | $this->call('preset',['type'=>'bootstrap']); 64 | } 65 | 66 | /** 67 | * Install the "vue" preset. 68 | * 69 | * @return void 70 | */ 71 | protected function vue() 72 | { 73 | $this->call('preset',['type'=>'vue']); 74 | 75 | } 76 | 77 | /** 78 | * Install the "react" preset. 79 | * 80 | * @return void 81 | */ 82 | protected function react() 83 | { 84 | $this->call('preset',['type'=>'react']); 85 | } 86 | 87 | /** 88 | * Install the "element-ui" preset. 89 | * 90 | * @return void 91 | */ 92 | protected function element() 93 | { 94 | Element::install(); 95 | 96 | $this->info('Element scaffolding installed successfully.'); 97 | $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/Commands/Presets/element-stubs/ExampleComponent.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | - 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 立即创建 44 | 取消 45 | 46 | 47 | 48 | 49 | 50 | 51 | 74 | -------------------------------------------------------------------------------- /src/Commands/Presets/Element.php: -------------------------------------------------------------------------------- 1 | '^0.15.3' , 39 | 'babel-core' => '^6.17.0' , 40 | 'babel-loader' => '^6.2.5' , 41 | 'babel-preset-es2015' => '^6.24.1' , 42 | 'bootstrap-sass' => '^3.3.7' , 43 | 'cross-env' => '^5.1.4' , 44 | 'css-loader' => '^0.25.0' , 45 | 'element-ui' => '^2.0.0' , 46 | 'jquery' => '^3.1.0' , 47 | 'laravel-mix' => '0.*' , 48 | 'lodash' => '^4.16.4' , 49 | 'style-loader' => '^0.13.1' , 50 | 'vue' => '^2.5.2' , 51 | 'vue-loader' => '^13.3.0' , 52 | ] + Arr::except( 53 | $packages , [ 54 | '@babel/preset-react' , 55 | 'react' , 56 | 'react-dom' , 57 | 'bootstrap' , 58 | 'popper.js' , 59 | 'sass-loader' , 60 | 'sass' , 61 | 'resolve-url-loader' 62 | ] 63 | ); 64 | } 65 | 66 | /** 67 | * Update the Webpack configuration. 68 | * 69 | * @return void 70 | */ 71 | protected static function updateWebpackConfiguration() 72 | { 73 | copy(__DIR__.'/element-stubs/webpack.mix.js', base_path('webpack.mix.js')); 74 | } 75 | 76 | /** 77 | * Update the example component. 78 | * 79 | * @return void 80 | */ 81 | protected static function updateComponent() 82 | { 83 | (new Filesystem)->delete( 84 | resource_path('js/components/Example.js') 85 | ); 86 | 87 | copy( 88 | __DIR__.'/element-stubs/ExampleComponent.vue', 89 | resource_path('js/components/ExampleComponent.vue') 90 | ); 91 | } 92 | 93 | /** 94 | * copy the base App component 95 | * 96 | * @return void 97 | */ 98 | protected static function AppComponent() 99 | { 100 | (new Filesystem)->delete( 101 | resource_path('js/App.vue') 102 | ); 103 | 104 | copy( 105 | __DIR__.'/element-stubs/App.vue', 106 | resource_path('js/App.vue') 107 | ); 108 | } 109 | 110 | /** 111 | * Update the bootstrapping files. 112 | * 113 | * @return void 114 | */ 115 | protected static function updateBootstrapping() 116 | { 117 | copy(__DIR__.'/element-stubs/bootstrap.js', resource_path('js/bootstrap.js')); 118 | } 119 | 120 | /** 121 | * Update the Sass files for the application. 122 | * 123 | * @return void 124 | */ 125 | protected static function updateSass() 126 | { 127 | copy(__DIR__.'/element-stubs/_variables.scss', resource_path('sass/_variables.scss')); 128 | copy(__DIR__.'/element-stubs/app.scss', resource_path('sass/app.scss')); 129 | } 130 | 131 | /** 132 | * Update the app.js files. 133 | * 134 | * @return void 135 | */ 136 | protected static function updateAppBoot() 137 | { 138 | copy(__DIR__.'/element-stubs/app.js', resource_path('js/app.js')); 139 | } 140 | } 141 | --------------------------------------------------------------------------------
You Should Try Element (This is in /resources/js/App.vue)