ChrisS
ChrisS

Reputation: 744

form Class not Found in Laravel

I'm new to Laravel and following the ACL Instructions of the Laravel 4 Cookbook.

github tutorial 4 code

ACL tutorial

I made a forms directory in app/ and put the 2 ****Form.php files in there. Now I have created a GroupController and a addAction (just like in the example). But when i Call the add Route: localhost:8000/group/add I got this error:

Class 'GroupForm' not found

line 7 in GroupController$form = new GroupForm();

I did composer dump-autoload.

But still get the error message.

Any help?

Composer.json file:

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "laravel/framework": "4.2.*"
},
"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},
"scripts": {
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ]
},
"config": {
    "preferred-install": "dist"
},
"minimum-stability": "stable"

}

Upvotes: 1

Views: 1278

Answers (3)

Brent Connor
Brent Connor

Reputation: 628

I just want to mention that if you're using Laravel 5 Html and Form have been removed because they are not core components.

  1. Add requirement for Illuminate Html in composer.json

    "illuminate/html": "~5.0"

  2. Update composer

    update composer

  3. In config/app.php

    a. Add the service provider to the providers array:

    'Illuminate\Html\HtmlServiceProvider'

    b. Add these two lines in the aliases array:

    'Form'=> 'Illuminate\Html\FormFacade', 'HTML'=> 'Illuminate\Html\HtmlFacade'

Upvotes: 2

Ihab Shoully
Ihab Shoully

Reputation: 2321

Yeah, first add the "app/forms" autoload in composer.json

then run

composer dump-autoload

Upvotes: 2

Vernard Luz
Vernard Luz

Reputation: 291

Add the location of your ***Form.php to your composer autoload. It should work after that.

Upvotes: 3

Related Questions