Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Radiosilent's avatar

Laravel 101, url to route to controller to blade

I'm working on a Laravel project that was working fairly well until I attempted to add Bootstrap 5.3. The problems are certainly something that I introduced, but the entire project became unstable and has devolved into not loading beyond the canned Laravel Jetstream pages. This is Laravel / Vagrant / Homestead, most current versions of everything (as far as I know).

  • URL is pcs2025.test
  • when I browse to pcs2025.test I go to the Jetstream landing page, then to login page, then to dashboard page, as expected
  • I added additional pages starting at pcs2025.test/positions. These were working fine.
  • I tried to add styles and functionality with bootstrap. Was going well for a while, then I pulled in some older code and my pages malfunctioned. Bootstrap styling disappeared, no trace of Divs, bootstrap icons, bullets, etc.
  • As I tried to work my way back things got worse, so I ripped everything out and want to start from scratch (plenty of backups, so can get back up to current quickly if I can figure out what happened).
  • I'm testing now with a plain vanilla route/controller/blade, but can't get it to launch.
  • Current status: pcs2025.test launches the Jetstream pages flawlessly (thanks Taylor and team!).
  • pcs2025.test/positions (or pcs2025/postions/1 to pass an id#) goes to a white screen, nothing else.

Second part of the question: How can I version control this entire project to avoid problems like this? I have the entire project on git (admittedly I don't understand it well) but when I try to reset or roll back I always have problems.

Can someone please get me pointed in the right direction? You'll probably have a good laugh in the process. I'm an oldschool OOP .exe programmer, trying to broaden my horizons. I sincerely appreciate all of the work that goes into keeping up with all of this technology...it's a whole different world!

Thanks so much for your help.

Route (mine is the very last line, everything else is Jetstream out of the box):

0 likes
2 replies
LaryAI's avatar
Level 58

To address the issues you're facing with your Laravel project, let's break it down into two parts: fixing the route/controller/blade setup and improving your version control with Git.

Part 1: Fixing the Route/Controller/Blade Setup

  1. Check Your Routes: Ensure that your routes are correctly defined in the web.php file. For example, if you want to access pcs2025.test/positions, you should have a route like this:

    // routes/web.php
    Route::get('/positions', [PositionController::class, 'index']);
    
  2. Create the Controller: Make sure you have a controller named PositionController with an index method. You can create it using Artisan if it doesn't exist:

    php artisan make:controller PositionController
    

    Then, define the index method:

    // app/Http/Controllers/PositionController.php
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    
    class PositionController extends Controller
    {
        public function index()
        {
            return view('positions.index');
        }
    }
    
  3. Create the Blade View: Ensure you have a Blade view file at resources/views/positions/index.blade.php. You can start with a simple HTML structure to test:

    <!-- resources/views/positions/index.blade.php -->
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Positions</title>
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="container">
            <h1>Positions Page</h1>
            <p>This is the positions page.</p>
        </div>
    </body>
    </html>
    
  4. Check for Errors: If you still see a white screen, check the Laravel logs in storage/logs/laravel.log for any errors that might give you more insight into what's going wrong.

Part 2: Version Control with Git

  1. Basic Git Workflow: Make sure you understand the basic Git workflow. Here’s a simple guide:

    • Initialize Git (if not already):

      git init
      
    • Add Changes:

      git add .
      
    • Commit Changes:

      git commit -m "Your commit message"
      
    • Push to Remote:

      git push origin main
      
  2. Using Branches: Use branches to experiment with new features or changes without affecting the main codebase:

    git checkout -b feature/your-feature-name
    
  3. Reverting Changes: If you need to revert to a previous commit, you can use:

    git checkout <commit-hash>
    

    Or, to reset the current branch to a previous state:

    git reset --hard <commit-hash>
    
  4. Learning Resources: Consider using resources like the official Git documentation or tutorials on Laracasts to deepen your understanding of Git.

By following these steps, you should be able to resolve the issues with your Laravel project and manage your code more effectively with Git. If you encounter specific errors, feel free to provide more details for further assistance.

Radiosilent's avatar

Here's what finally worked:

1 - Revert to an earlier commit [ git reset --hard (commit-id) ]

2 - Delete the resulting Vendors folder

3 - [Composer Install] to rebuild the vendors folder

Thanks!

Please or to participate in this conversation.