CSS does not load in Laravel 8 + Jetstream on XAMPP

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# Fixing CSS Loading Issues in Laravel Jetstream: XAMPP vs. Artisan Serve Conflicts As developers diving into the world of Laravel, setting up local development environments can often introduce unexpected hurdles. One common point of friction, especially when dealing with asset loading like CSS or JavaScript in frameworks such as Jetstream, is the inconsistency between running via the built-in PHP server (`php artisan serve`) and running through a full stack environment like XAMPP (Apache). This post will diagnose why your CSS links might fail in one setup but work in another, and provide a robust solution to ensure your assets load correctly regardless of your local server configuration. ## The Root of the Problem: Server Context Differences The issue you are encountering—where asset paths like `localhost/app/css` work fine with `php artisan serve` but fail under XAMPP—is almost always related to how the web server handles URL resolution and public directory mapping. When you use `php artisan serve`, Laravel manages the routing directly, and the pathing is generally handled seamlessly by the PHP process itself. However, when running through XAMPP (Apache), the request passes through Apache, which relies on the virtual host configuration and the physical file structure within your `htdocs` folder. The problem often lies in using absolute paths or relative paths that don't correctly map to the web root defined by the server environment. In a Laravel application, all publicly accessible files must reside within the `public` directory. ## The Developer Solution: Adopting Laravel Asset Helpers The most reliable way to ensure assets load consistently across different environments is to stop relying on hardcoded absolute paths and instead leverage Laravel's dedicated asset helper functions. This forces the framework to correctly resolve the path relative to the application's public root, making it server-agnostic. ### 1. Use the `asset()` Helper for Public Assets Instead of linking directly to a file path like `/app/css/style.css`, you should use the global `asset()` helper function. This function generates a URL that is correctly prefixed with your application's base URL, which resolves dynamically whether you are running on Artisan Serve or Apache. **Incorrect (Environment Dependent):** ```html ``` **Correct (Server Agnostic):** ```html {{-- This uses the base URL defined by Laravel, making it work everywhere --}} ``` ### 2. Verify Your Public Directory Structure Ensure your CSS files are correctly placed within the `public` directory, as this is the root entry point for all web requests in Laravel. If you have a structure like: ``` your-project/ ├── app/ │ └── css/ │ └── style.css <-- Problematic location for direct linking ├── public/ │ └── css/ <-- Correct location for web access └── ... ``` You must ensure your view files are referencing the path *relative* to the `public` folder, which is what the `asset()` helper handles perfectly. ## Best Practices for Local Development When setting up local development environments, it is crucial to understand that the server environment (XAMPP vs. Artisan) dictates the base URL (`http://localhost/` vs. the specific domain setup). By sticking to framework conventions, you abstract away these environmental differences. Following the principles outlined by Laravel documentation ensures your application remains portable and maintainable, aligning with best practices for building robust applications on platforms like those discussed at [laravelcompany.com](https://laravelcompany.com). ## Conclusion The discrepancy you observed is a classic symptom of environment-specific path resolution rather than a fundamental bug in the code itself. By refactoring your asset links to use Laravel's built-in helpers, specifically `asset()`, you eliminate this dependency on the specific local server setup. This approach guarantees that your CSS and JavaScript files will load correctly whether you are developing locally with PHP's server or deploying through a full stack like XAMPP. Always prioritize framework conventions when building applications; they provide the most stable foundation for development.