Livewire Starter Kit - v1.0-beta1
Troubleshooting
This guide helps you diagnose and resolve common issues with the Livewire Starter Kit.
General Debugging
Enable Debug Mode
For development, enable debug mode in your .env file:
APP_DEBUG=true
APP_ENV=local
Never enable debug mode in production as it can expose sensitive information.
Clear Caches
When experiencing unexpected behavior, clear all caches:
# Clear all caches
php artisan optimize:clear
# Or clear specific caches
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
Check Logs
Review application logs for errors:
# View latest logs
tail -f storage/logs/laravel.log
# View specific log file
cat storage/logs/laravel-2024-01-05.log
Installation Issues
Composer Installation Fails
Problem: Composer install fails with dependency conflicts
Solutions:
- Update Composer:
composer self-update
- Clear Composer cache:
composer clear-cache
- Use specific PHP version:
composer install --ignore-platform-reqs
- Check PHP extensions:
php -m | grep -E "(mbstring|xml|zip|curl|bcmath|gd)"
NPM Installation Issues
Problem: NPM install fails or takes too long
Solutions:
- Clear NPM cache:
npm cache clean --force
- Delete node_modules and reinstall:
rm -rf node_modules package-lock.json
npm install
- Use different registry:
npm install --registry https://registry.npmjs.org/
Database Connection Issues
Problem: Database connection errors
Solutions:
- Check database credentials in
.env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
- Test database connection:
php artisan tinker
>>> DB::connection()->getPdo();
- Create database if it doesn't exist:
CREATE DATABASE your_database_name;
- Check database service is running:
# MySQL
sudo service mysql status
# PostgreSQL
sudo service postgresql status
Environment Issues
Application Key Missing
Problem: "No application encryption key has been specified"
Solution:
php artisan key:generate
Permission Errors
Problem: Permission denied errors for storage or cache directories
Solutions:
- Fix permissions:
sudo chown -R $USER:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache
- For development (Linux/Mac):
chmod -R 777 storage bootstrap/cache
Environment Variables Not Loading
Problem: Environment variables from .env file not working
Solutions:
- Check
.envfile exists:
ls -la .env
- Verify file format (no spaces around
=):
# Correct
APP_NAME="My App"
# Incorrect
APP_NAME = "My App"
- Clear config cache:
php artisan config:clear
- Check file encoding (must be UTF-8 without BOM)
Livewire Issues
Component Not Updating
Problem: Livewire component not responding to user interactions
Solutions:
-
Check for JavaScript errors in browser console
-
Verify wire: directives:
<!-- Correct -->
<button wire:click="increment">+</button>
<!-- Incorrect -->
<button onclick="increment()">+</button>
- Add wire:key to dynamic elements:
@foreach($items as $item)
<div wire:key="item-{{ $item->id }}">
{{ $item->name }}
</div>
@endforeach
- Check component mounting:
public function mount(): void
{
// Initialize component state
}
Validation Not Working
Problem: Form validation not displaying errors
Solutions:
- Check validation rules:
protected function rules(): array
{
return [
'email' => 'required|email',
'password' => 'required|min:8',
];
}
- Display errors in template:
<x-artisanpack-input wire:model="email" :error="$errors->first('email')" />
- Use proper validation method:
public function save(): void
{
$this->validate(); // This triggers validation
// Save logic here
}
CSRF Token Mismatch
Problem: "CSRF token mismatch" errors
Solutions:
- Include CSRF token in forms:
<form>
@csrf
<!-- form fields -->
</form>
- Check session configuration:
SESSION_DRIVER=file
SESSION_LIFETIME=120
- Clear sessions:
php artisan session:table
php artisan migrate
Volt Issues
Volt Component Not Found
Problem: Volt component not loading or found
Solutions:
- Check Volt configuration in
config/volt.php:
'mount' => [
resource_path('views/pages'),
resource_path('views/livewire'),
],
-
Verify file location matches mount paths
-
Clear view cache:
php artisan view:clear
- Check component syntax:
<?php
use function Livewire\Volt\{state};
state(['count' => 0]);
$increment = fn() => $this->count++;
?>
<div>
<h1>{{ $count }}</h1>
<button wire:click="increment">+</button>
</div>
ArtisanPack UI Issues
Components Not Styling Correctly
Problem: ArtisanPack UI components not displaying proper styles
Solutions:
- Check Tailwind CSS is compiled:
npm run dev
# or for production
npm run build
- Verify Tailwind configuration includes ArtisanPack UI paths:
// tailwind.config.js
content: [
'./resources/**/*.blade.php',
'./vendor/artisanpack-ui/livewire-ui-components/resources/**/*.blade.php',
],
- Clear compiled assets:
rm -rf public/build/*
npm run dev
Component Not Rendering
Problem: ArtisanPack UI components not rendering or showing errors
Solutions:
- Check component exists:
php artisan vendor:publish --tag=artisanpack-ui-config
- Verify correct syntax:
<!-- Correct -->
<x-artisanpack-button variant="primary">Click me</x-artisanpack-button>
<!-- Incorrect -->
<artisanpack:button variant="primary">Click me</artisanpack:button>
- Check for component conflicts with other packages
Authentication Issues
Login Not Working
Problem: Users cannot log in with correct credentials
Solutions:
- Check user exists in database:
php artisan tinker
>>> User::where('email', 'test@example.com')->first();
- Verify password hashing:
// Check if password is hashed correctly
Hash::check('password', $user->password)
- Check auth configuration in
config/auth.php:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],
- Clear sessions and try again:
php artisan session:flush
Email Verification Not Working
Problem: Email verification emails not being sent
Solutions:
- Check mail configuration in
.env:
MAIL_MAILER=smtp
MAIL_HOST=your-smtp-host
MAIL_FROM_ADDRESS=noreply@yourdomain.com
- Test mail configuration:
php artisan tinker
>>> Mail::raw('Test email', function($msg) { $msg->to('test@example.com'); });
- Check queue configuration if using queued emails:
php artisan queue:work
Password Reset Issues
Problem: Password reset functionality not working
Solutions:
- Check password reset table exists:
php artisan migrate:status
-
Verify mail configuration (same as email verification)
-
Check token expiration in
config/auth.php:
'passwords' => [
'users' => [
'expire' => 60, // minutes
],
],
Performance Issues
Slow Page Loading
Problem: Pages loading slowly in development or production
Solutions:
- Enable caching in production:
php artisan config:cache
php artisan route:cache
php artisan view:cache
- Check for N+1 query problems:
# Install Laravel Debugbar for development
composer require barryvdh/laravel-debugbar --dev
- Optimize Composer autoloader:
composer dump-autoload --optimize
- Use proper database indexing:
// In migration
$table->index(['user_id', 'created_at']);
Memory Issues
Problem: Out of memory errors
Solutions:
- Increase PHP memory limit:
// php.ini
memory_limit = 256M
- Optimize large dataset queries:
// Use chunking for large datasets
User::chunk(100, function ($users) {
foreach ($users as $user) {
// Process user
}
});
- Clear variables in loops:
foreach ($largeArray as $item) {
// Process item
unset($item);
}
Development Server Issues
Vite Not Working
Problem: Vite development server not starting or assets not loading
Solutions:
- Check Node.js version:
node --version # Should be 18+
- Install dependencies:
npm install
- Start Vite manually:
npm run dev
-
Check Vite configuration in
vite.config.js -
Clear Vite cache:
rm -rf node_modules/.vite
npm run dev
Laravel Server Issues
Problem: php artisan serve not working or showing errors
Solutions:
- Check PHP version:
php --version # Should be 8.2+
- Use specific port:
php artisan serve --port=8080
- Check for port conflicts:
lsof -i :8000
- Use Laravel Herd instead (macOS/Windows):
- Install Laravel Herd
- Navigate to project directory
- Access via
https://project-name.test
Testing Issues
Tests Not Running
Problem: Tests failing to run or giving errors
Solutions:
- Check testing environment in
phpunit.xml:
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
- Create testing database:
touch database/database.sqlite
- Run specific test:
php artisan test --filter=testUserCanLogin
- Check test dependencies:
composer require --dev pestphp/pest
Tests Failing Unexpectedly
Problem: Previously passing tests now failing
Solutions:
- Clear test cache:
php artisan test --recreate-databases
- Check for data pollution between tests:
use RefreshDatabase; // Add this trait to test classes
- Reset application state:
beforeEach(function () {
$this->refreshApplication();
});
Browser-Specific Issues
JavaScript Errors
Problem: JavaScript errors in browser console
Solutions:
-
Check for Livewire Alpine conflicts:
- Livewire 3 includes Alpine.js automatically
- Don't include Alpine.js separately
-
Verify asset compilation:
npm run dev # or npm run build
-
Clear browser cache and hard refresh (Ctrl+F5)
-
Check network tab for failed asset requests
CSRF Issues in AJAX Requests
Problem: CSRF errors when making AJAX requests
Solutions:
- Include CSRF token in meta tag:
<meta name="csrf-token" content="{{ csrf_token() }}">
- Set up AJAX headers:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
Production Issues
500 Internal Server Error
Problem: Server error in production
Solutions:
- Check web server error logs:
# Apache
tail -f /var/log/apache2/error.log
# Nginx
tail -f /var/log/nginx/error.log
- Check PHP error logs:
tail -f /var/log/php/php8.2-fpm.log
- Verify file permissions:
sudo chown -R www-data:www-data /var/www/yourapp
sudo chmod -R 755 /var/www/yourapp
- Check environment configuration:
APP_ENV=production
APP_DEBUG=false
Assets Not Loading
Problem: CSS/JS assets not loading in production
Solutions:
- Build production assets:
npm run build
-
Check web server configuration for static file serving
-
Verify asset URLs in browser network tab
-
Check file permissions for public directory
Getting Help
If you can't resolve an issue:
- Search existing issues in the repository
- Check Laravel documentation for Laravel-specific issues
- Check Livewire documentation for Livewire-specific issues
- Create a detailed bug report with:
- Steps to reproduce
- Expected vs actual behavior
- Environment information
- Error messages and logs
- Screenshots if applicable
Debug Tools
Useful Debug Packages
For development, consider installing these debug tools:
# Laravel Debugbar
composer require barryvdh/laravel-debugbar --dev
# Laravel Telescope (for detailed application insights)
composer require laravel/telescope --dev
# Ray (for advanced debugging)
composer require spatie/laravel-ray --dev
Browser Tools
- Browser Developer Tools (F12)
- Laravel Debug Bar (shows queries, performance, etc.)
- Vue.js DevTools (if using Vue components)
- React Developer Tools (if using React components)
Command Line Debug
# Check PHP configuration
php -i | grep memory_limit
# Check installed extensions
php -m
# Check Composer dependencies
composer show
# Check NPM packages
npm list
# Check disk space
df -h
# Check memory usage
free -m
Remember to always test in a development environment first and keep backups before making changes to production systems.