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

chodul's avatar

"Call to undefined function App\Http\Controllers\requests()" .. Requests folder missing

Hello guys,

i'm starting with Laravel with Laravel From Scratch tutorial. I get stuck on forms. Everything i have as it is on tutorial but i notice that i have not Requests folder in my folder structure. Can you help me please why is that or what i did wrong. Thanks

0 likes
8 replies
Snapey's avatar

in 5.3 many of the folders are only created if you need them.

This folder missing would not give the error you are seeing

Paste some code from your controller? put three backticks ` before and after a code block

chodul's avatar

Hello. I follow Laravel From Scratch tutorial exactly. Here is code from my NotesController.php


namespace App\Http\Controllers;

use Illuminate\Http\Request;


use App\Http\Controllers\Controller;


class NotesController extends Controller
{
    public function store()
        
    {
        return requests()->all();   
    }
    
}```


I created request through php artisan and Request folder is now there. I see that error because function request() does not exist anywhere. I think this had to be in request folder already.
chodul's avatar

This is from show.blade.php

@extends('layout')

@section('content')

    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <h1>{{ $card->title }}</h1>
            
            <ul class="list-group">
            @foreach ($card->notes as $note)
            
                <li class="list-group-item">{{ $note->body }}</li>
            
            @endforeach
            </ul>
            
            <hr>
            
            <h3>Add a new note</h3>
            
            <form method="POST" action="/cards/{{ $card->id }}/notes">
                {{ csrf_field() }}
                <div class="form-group">
                    <textarea name="body" class="form-control"></textarea>
                </div>
                
                <div class="form-group">
                    <button type="submit" class="btn btn-primary">Add note</button>
                </div>
            </form>
        </div>
    </div>

@stop
Gog0's avatar

Do

public function store(Request $request)
        
{
    return $request->all();   
}

You forgot the dependency injection.

chodul's avatar

Now i get: "FatalErrorException in NotesController.php line 16: Function name must be a string"

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;


use App\Http\Controllers\Controller;


class NotesController extends Controller
{
    public function store(Request $request)
        
    {
        return $request()->all();   
    }
    
}


Gog0's avatar

Oups, no parenthesis on request

chodul's avatar

Thank you guys for your quick help here :) .. works fine now.

Please or to participate in this conversation.