This guide covers common issues you might encounter when setting up, developing, or using the Universal application.
Problem: Docker containers fail to start or have connection issues. Solution:
- Make sure Docker is running on your system
- Try stopping and removing the containers, then rebuilding:
docker-compose down docker-compose up -d --build - Check for port conflicts with other running services
Problem: Database connection errors in Docker environment. Solution:
- Verify database container is running:
docker-compose ps - Check the database credentials in your
.envfile - Ensure the database hostname matches the service name in docker-compose.yml
- Wait a moment for the database to fully initialize before connecting
Problem: Composer install fails with PHP version requirements. Solution:
- Ensure you're using PHP 8.2 or higher:
php -v - If using Docker, validate the PHP version in your container
- Try clearing Composer cache:
composer clear-cache - Update Composer:
composer self-update
Problem: NPM/Vite build errors. Solution:
- Clear npm cache:
npm cache clean --force - Delete node_modules and reinstall:
rm -rf node_modules && npm install - Check Node.js version (18+ required):
node -v - Update npm:
npm install -g npm@latest
Problem: Database migrations fail. Solution:
- Ensure database connection is properly configured in
.env - Try refreshing the database:
php artisan migrate:fresh - For specific migration errors, check the error message for clues about table or column issues
- If a migration is stuck, try:
php artisan migrate:refresh
Problem: "No application encryption key has been specified" error. Solution:
- Generate a new application key:
php artisan key:generate - Verify the key is set in your
.envfile - Restart the web server after generating the key
Problem: File upload or storage issues. Solution:
- Ensure storage directory is writable:
chmod -R 775 storage - Create symbolic link:
php artisan storage:link - In Docker, check container permissions and volumes
Problem: WebSocket connections fail or do not receive real-time updates. Solution:
- Verify Laravel Reverb is running:
php artisan reverb:start - Check WebSocket configuration in
.env - Inspect browser console for connection errors
- Ensure the frontend is properly configured with Laravel Echo
Problem: Projections not updating or events not processing. Solution:
- Check if queue worker is running:
php artisan queue:work - Verify event handlers are registered in service providers
- Rebuild projections:
php artisan event-sourcing:rebuild {projector} - Check logs for event processing errors
Problem: Slow application response times. Solution:
- Enable Laravel query logging to identify slow queries
- Check if projections need optimization
- Verify frontend caching and data fetching strategies
- Consider running
php artisan optimizein production
Problem: Authentication fails or sessions expire quickly. Solution:
- Check Sanctum configuration in
config/sanctum.php - Verify session configuration in
config/session.php - Clear browser cookies and cache
- Check for CORS issues if using a separate frontend domain
Problem: TypeScript type errors. Solution:
- Run the type checking script:
npm run typecheck - Update TypeScript definitions if needed
- Check import paths and module resolution
- Verify compatibility between React and TypeScript versions
Problem: React components not rendering or updating properly. Solution:
- Check state management with React Query and XState
- Verify component props and key prop usage
- Use React Developer Tools to inspect component hierarchies
- Look for console errors in the browser developer tools
Problem: Application fails after deployment. Solution:
- Verify environment variables on the production server
- Check file permissions on the server
- Run
php artisan optimizeafter deployment - Ensure all required PHP extensions are installed
- Verify server requirements match Laravel 12 needs
- Check Laravel logs:
storage/logs/laravel.log - Verify PHP error logs
- Ensure all dependencies are installed
- Check file permissions
- CSRF token mismatch
- Regenerate token:
php artisan session:clear - Verify forms include CSRF token field
- Check session configuration
- Permission issues
- Check authorization policies
- Verify user authentication status
- Ensure proper CORS headers if using API
If you've tried the solutions above and still have issues:
- Check the existing documentation
- Search for similar issues in the project repository
- Open a detailed issue including:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Log outputs
- Environment details (PHP version, Laravel version, etc.)