Create Laravel Boiler Plate
1. Install Laravel
  1. 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
  2. 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`)
  3. Set up config/app/php
    • Change UTC to Africa/Harare Africa/Harare
  4. 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
  5. Sail Up
If authentication is needed
2. Install Jet Stream
  1. Install Jet Stream
    1. sail composer require laravel/jetstream
    2. sail php artisan jetstream:install livewire
    3. npm install
    4. sail php artisan migrate
    5. sail php artisan vendor:publish --tag=jetstream-views
  2. Install spatie/laravel-permission
    1. sail composer require spatie/laravel-permission
    2. sail php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
    3. sail php artisan migrate
    4. Put use HasRoles; in Models/User.php
  3. Setup permissions
    1. 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);
                                        
    2. 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');
                                        
    3. sail php artisan make:migration add_hash_to_users_table
      •     Schema::table('users', function (Blueprint $table) {
                $table->string('hash', 30)->after('profile_photo_path');
            });
                                        
If Mix/Webpack is to be used
3. Install Laravel Mix
  1. Copy webpack.mix.js from previous project and strip out all that not need in a fresh project
  2. Replace
  3. 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
  1. sail composer require barryvdh/laravel-debugbar --dev
    • sail php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
  2. Publish ignition config and change to dark mode
    • sail php artisan vendor:publish --provider="Spatie\LaravelIgnition\IgnitionServiceProvider" --tag="ignition-config"
  3. sail composer require spatie/laravel-stubs --dev
    • sail php artisan spatie-stub:publish
Already Know the Details of Your Project?