PHP code example of artflow-studio / starterkit

1. Go to this page and download the library: Download artflow-studio/starterkit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

artflow-studio / starterkit example snippets


// Automatic Spatie Laravel Permission detection
AuthService::redirectAfterLogin($user)
    ↓
    Checks roles:
    - admin? → /admin/dashboard
    - moderator? → /moderator/dashboard
    - manager? → /manager/dashboard
    - else → /dashboard

// In app/Services/AuthService.php (published with install command)

public static function redirectAfterLogin($user)
{
    if ($user->isAdmin()) {
        return redirect('/admin/dashboard');
    }
    
    if (!$user->email_verified_at) {
        return redirect('/email/verify');
    }
    
    return redirect('/dashboard');
}

// vendor/artflow-studio/starterkit/src/Providers/StarterKitFortifyServiceProvider.php

public function register(): void
{
    // All 20 response contracts are bound here
    $this->app->singleton(LoginResponse::class, StarterKitLoginResponse::class);
    $this->app->singleton(RegisterResponse::class, StarterKitRegisterResponse::class);
    // ... + 18 more
}

// Role-based redirects (automatic Spatie support)
AuthService::redirectAfterLogin($user, $request)

// Post-registration routing
AuthService::redirectAfterRegister($user, $request)

// Password reset redirect
AuthService::redirectAfterPasswordReset($user)

// Pre-login validation
AuthService::beforeLogin($request)

// Post-login hooks
AuthService::afterLogin($user, $request)

// Post-registration hooks
AuthService::afterRegister($user, $request)

// Pre-logout validation
AuthService::beforeLogout($user)

// Post-logout hooks
AuthService::afterLogout($user)

// Check if 2FA 

public static function redirectAfterLogin(Model $user, ?Request $request = null): string
{
    // Check if Spatie is available
    if (method_exists($user, 'hasRole')) {
        // Admin users
        if ($user->hasRole('admin')) {
            return '/admin/dashboard';
        }
        
        // Moderators
        if ($user->hasRole('moderator')) {
            return '/moderator/dashboard';
        }
        
        // Managers
        if ($user->hasRole('manager')) {
            return '/manager/dashboard';
        }
    }
    
    // Default for all other users
    return '/dashboard';
}

use ArtflowStudio\StarterKit\Services\AuthService;

use App\Services\AuthService;

// app/Services/AuthService.php

namespace App\Services;

use ArtflowStudio\StarterKit\Services\AuthService as BaseAuthService;
use Illuminate\Database\Eloquent\Model;

class AuthService extends BaseAuthService
{
    public static function redirectAfterLogin(Model $user, $request = null): string
    {
        // Premium users
        if ($user->subscription_status === 'premium') {
            return '/premium/dashboard';
        }
        
        // Fall back to base logic (Spatie roles, etc.)
        return parent::redirectAfterLogin($user, $request);
    }
}

return [
    'layouts' => [
        'auth' => env('STARTERKIT_AUTH_LAYOUT', 'particles'),
        'admin' => env('STARTERKIT_ADMIN_LAYOUT', 'sidebar'),
    ],

    'dark_mode' => [
        'enabled' => true,
        'default' => 'light',
    ],

    'assets' => [
        'auth' => [
            'css' => 'vendor/artflow-studio/starterkit/assets/auth.css',
            'js' => 'vendor/artflow-studio/starterkit/assets/auth.js',
        ],
        'admin' => [
            'css' => 'vendor/artflow-studio/starterkit/assets/admin.css',
            'js' => 'vendor/artflow-studio/starterkit/assets/admin.js',
        ],
    ],
];

return [
    'layouts' => [
        'auth' => env('STARTERKIT_AUTH_LAYOUT', 'particles'),
        'admin' => env('STARTERKIT_ADMIN_LAYOUT', 'sidebar'),
    ],

    'dark_mode' => [
        'enabled' => true,
        'default' => 'light',
    ],

    'assets' => [
        'auth' => [
            'css' => 'vendor/artflow-studio/starterkit/assets/auth.css',
            'js' => 'vendor/artflow-studio/starterkit/assets/auth.js',
        ],
        'admin' => [
            'css' => 'vendor/artflow-studio/starterkit/assets/admin.css',
            'js' => 'vendor/artflow-studio/starterkit/assets/admin.js',
        ],
    ],
];

// Create test users with roles
php artisan tinker

use App\Models\User;
use Spatie\Permission\Models\Role;

// Create roles
Role::create(['name' => 'admin']);
Role::create(['name' => 'moderator']);

// Create admin user
$admin = User::factory()->create(['email' => '[email protected]']);
$admin->assignRole('admin');

// Create moderator user
$mod = User::factory()->create(['email' => '[email protected]']);
$mod->assignRole('moderator');

// routes/web.php
Route::middleware(['custom-auth'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/admin', [AdminController::class, 'index'])->name('admin');
});

// app/Providers/EventServiceProvider.php
protected $listen = [
    \Illuminate\Auth\Events\Login::class => [
        \App\Listeners\AuthenticationListener::class,
    ],
    \Illuminate\Auth\Events\Registered::class => [
        \App\Listeners\AuthenticationListener::class,
    ],
    \Illuminate\Auth\Events\Logout::class => [
        \App\Listeners\AuthenticationListener::class,
    ],
];
bash
# 1. Install via Composer
composer isan starterkit:install

# 3. Start the server
php artisan serve
bash
# Basic installation (default)
php artisan starterkit:install

# Choose auth layout during installation
php artisan starterkit:install --layout=glass

# Publish AuthService to app/Services for customization
php artisan starterkit:install --publish-auth-service

# Force overwrite existing files
php artisan starterkit:install --force

# Combine options
php artisan starterkit:install --publish-auth-service --force
bash
# Run Laravel migrations
php artisan migrate

vendor/artflow-studio/starterkit/src/Services/AuthService.php
bash
php artisan starterkit:install --publish-auth-service
bash
# These publish automatically with: php artisan starterkit:install

php artisan vendor:publish --tag=starterkit-auth-layouts    # Auth views (14 layouts)
php artisan vendor:publish --tag=starterkit-assets          # CSS/JS files
php artisan vendor:publish --tag=starterkit-config          # config/starterkit.php
bash
# Admin layouts (not needed for basic auth)
php artisan vendor:publish --tag=starterkit-admin-layouts

# Database migrations
php artisan vendor:publish --tag=starterkit-migrations

# Documentation
php artisan vendor:publish --tag=starterkit-docs

# Fortify configuration (if you need to customize Fortify)
php artisan vendor:publish --tag=starterkit-fortify-config
blade
<!-- resources/views/admin/dashboard.blade.php -->
@extends('starterkit::layouts.admin.sidebar')

@section('content')
    <div class="container-fluid">
        <h1>Admin Dashboard</h1>
        <!-- Your admin content -->
    </div>
@endsection
bash
php artisan config:clear
php artisan cache:clear  
php artisan route:clear
bash
composer dump-autoload
php artisan clear-compiled
php artisan config:clear
php artisan cache:clear
bash
php artisan tinker --execute="dd(app(Laravel\Fortify\Contracts\LoginResponse::class));"
bash
php artisan starterkit:install                    # Standard install
php artisan starterkit:install --layout=glass     # Custom layout
php artisan starterkit:install --force            # Overwrite existing
bash
php artisan serve
# Visit: http://localhost:8000/test/layouts
bash
php artisan test
bash
php artisan optimize:clear
php artisan starterkit:install --force
ls public/vendor/artflow-studio/starterkit/assets/
bash
php artisan fortify:install
php artisan migrate
php artisan starterkit:install
bash
chmod -R 755 storage bootstrap/cache
php artisan starterkit:install --force
bash
git clone https://github.com/rahee554/Laravel-Starter-Kit.git
cd Laravel-Starter-Kit
composer install
npm install

cp .env.example .env
php artisan key:generate

php artisan migrate
php artisan serve
npm run dev