Create Laravel Boiler Plate
1. Install Laravel
- Install Laravel
- Use the following command to install Laravel:
- curl -s "https://laravel.build/example-app?with=mysql" | bash
- Options: mysql, pgsql, mariadb, redis, memcached, meilisearch, minio, selenium, and mailpit
- Use the following command to install Laravel:
- Set up the environment file (`.env`)
- Copy `.env.example` to `.env` - cp .env.example .env
- Ensure the database name is the same as the Git repository
- Update the following values in the `.env` file:
- DB_HOST=mysql
- SESSION_DRIVER=file
- QUEUE_CONNECTION=sync (if you don't want to use `php artisan queue:work`)
- Set up config/app/php
- Change UTC to Africa/Harare Africa/Harare
- Set up the `.gitignore` file
- Ignore the following files:
- /public/mix-manifest.json
- /public/css/app.css
- /public/css/app.css.map
- /public/js/app.js
- /public/js/app.js.LICENSE.txt
- /public/js/app.js.map
- Ignore the following files:
- Sail Up
If authentication is needed
2. Install Jet Stream
- Install Jet Stream
- sail composer require laravel/jetstream
- sail php artisan jetstream:install livewire
- npm install
- sail php artisan migrate
- sail php artisan vendor:publish --tag=jetstream-views
- Install spatie/laravel-permission
- sail composer require spatie/laravel-permission
- sail php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
- sail php artisan migrate
- Put use HasRoles; in Models/User.php
- Setup permissions
-
sail php artisan make:migration setup_create_permissions
-
// god permissions $permission_god = Permission::create(['name' => 'play god']); $role_god = Role::create(['name' => 'god']); $role_god->givePermissionTo($permission_god); $permission_god->assignRole($role_god);
-
-
sail php artisan make:migration setup_create_admin_user
-
$god = new \App\Models\User(); $god->name = 'Ben God Taylor'; $god->email = 'ben@ngwenyaglass.co.sz'; $god->email_verified_at = now(); $god->password = '$2y$10$8S6KmBKS2ZwKualtAq4HueG4IKFA0sjw8YPad2awEwKCuCyGmzWjm'; $god->remember_token = Str::random(10); $god->save(); // give god roles $god->assignRole('god');
-
-
sail php artisan make:migration add_hash_to_users_table
-
Schema::table('users', function (Blueprint $table) { $table->string('hash', 30)->after('profile_photo_path'); });
-
-
sail php artisan make:migration setup_create_permissions
If Mix/Webpack is to be used
3. Install Laravel Mix
- Copy webpack.mix.js from previous project and strip out all that not need in a fresh project
- Replace
- Edit package.json and add following to scripts object
- "dev": "npm run development",
- "development": "mix",
- "watch": "mix watch",
- "watch-poll": "mix watch -- --watch-options-poll=1000",
- "hot": "mix watch --hot",
- "prod": "npm run production",
- "production": "mix --production",
3. Install Packages
-
sail composer require barryvdh/laravel-debugbar --dev
- sail php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
- Publish ignition config and change to dark mode
- sail php artisan vendor:publish --provider="Spatie\LaravelIgnition\IgnitionServiceProvider" --tag="ignition-config"
-
sail composer require spatie/laravel-stubs --dev
- sail php artisan spatie-stub:publish