0
votes

I am trying to enable html forms in laravel 5.2 so I can do something like this in my blade.php files.

<img src="{{ Html::image('Joe_Icon.png')}}" style="width:160px;height:100px;">

When I tried this initially I got an error that said Html was not found. I have added the following lines to my app.php file in the config folder, in the aliases array.

 'Form' => Collective\Html\FormFacade::class,
 'Html' => Collective\Html\HtmlFacade::class,

This is in my app.php file in the providers array.

    Collective\Html\HtmlServiceProvider::class,

Unfortunately now I get an error that says Class 'Collective\Html\HtmlServiceProvider not found. I have also used the command composer update and my composer is up to date so that is not the issue.

Here is my full composer.json file

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*"
    "laravelcollective/html": "^5.2"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "symfony/css-selector": "2.8.*|3.0.*",
    "symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ]
},
"config": {
    "preferred-install": "dist"
}
} 
1
This is what happens in terminal when I type composer update, so it seems everything is working normally with composer.ray
Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload filesray
Your composer.json above looks odd, you should have a lot more in the require section for a Laravel app. Do you possibly have two require sections?jszobody
did you try a composer dump-autoload after the update? It's not necessary, but it's worth tryingDamien Pirsy
for some reason I have two composer.json files, on in my home directory and one in my app. I have edited the composer.json file in my app with "laravelcollective/html": "^5.2" but I still get the same errorray

1 Answers

2
votes

You have to follow this order:

First remove/comment out the following lines from app.php

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

and

 Collective\Html\HtmlServiceProvider::class,

Now,

{
    "require": {
    "laravelcollective/html": "^5.2"
    }
}

Then composer update.

Now add back or remove comment from the app.php

Do a composer dump-autoload.