This question already has answers here:
FatalErrorException in HtmlServiceProvider.php line 36: laravel
(5 answers)
Closed 6 years ago.
Inside config/app.php file, I added the service provider to the list:
'Illuminate\Html\HtmlServiceProvider',
And added the aliases:
'Form' => 'Illuminate\Html\FormFacade',
'Html' => 'Illuminate\Html\HtmlFacade',
But I get:
FatalErrorException in HtmlServiceProvider.php line 36: Call to undefined method Illuminate\Foundation\Application::bindShared()
Solution 1
Go to the file Illuminate\Foundation\Application and replace bindShare with singleton. This will solve your problem.
bindShared has been renamed to $app->singleton().
This would change the core files and is nit recommended. But if are just looking for a quick fix, this would help. But I strongly suggest you to follow the second solution.
Solution 2
The main problem is because you are using the package Illuminate/HTML which is no longer mainted. You can use Laravelcollective/HTML instead of this.
First, comment out the references to Illuminate\Html in your config/app.php.
Next, do composer remove illuminate/html.
After that, do composer require laravelcollective/html.
Now uncomment the Illuminate\Html items in your config/app.php file and update references to Collective\Html instead of Illuminate\Html.
I think you should follow below steps to add HTML and FORM classes in laravel 5.
first open composer.JSON file and write following line after "laravel/framework": "5.2.*"
put comma(,) at last
"laravelcollective/html": "5.2.*"
now open command promt and type command "composer update"
It will take some time to upgrade.
after complete upgradation Register the service provider in config/app.php by adding the following value into the providers array:
Collective\Html\HtmlServiceProvider::class,
Register facades by adding these two lines in the aliases array:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
Hope this will solve your problem.
See this post
htmlserviceprovider
Related
I have tried and searched everything I could think of and I can not make Spatie UrlSigner work under Laravel.
Basically I have followed the step by step installation guide on his page.
Installed with composer.
Added the provider and facade in config/app.php:
'providers' => [
Spatie\UrlSigner\Laravel\UrlSignerServiceProvider::class,
],
'aliases' => [
'UrlSigner' => Spatie\UrlSigner\Laravel\UrlSignerFacade::class,
],
Then in my controller I included the facade using the alias:
use UrlSigner;
And tried to used it in some function:
public function publicShow() {
$url=UrlSigner::sign('http://example.com', 30);
return $url;
}
This gives me a fatal error:
Class 'UrlSigner' not found
I have tried different methods, even including the class itself which returned a different error about not being allowed to call the method statically. All in all I feel like I've no solution left.
I think this is something trivial that I'm missing but being quite a beginner with Laravel I can't for the life of me find out what it is.
Cheers!
Turns out that this was the correct way to load the package. After trying to install it on a different instance of Laravel and having everything work like a charm I did a bunch of comparing between those two.
Not sure why the very same facade worked on one instance and not on another despite using the exact same code on my end.
Solved it by deleting everything except .gitignore from the bootstrap/cache/ folder as suggested to a similar problem here.
Thanks to everyone who helped!
How would I go around using this class/library in Laravel:
https://github.com/planetteamspeak/ts3phpframework
I tried to include it in config/app.php providers like this:
planetteamspeak\ts3-php-framework\libraries\TeamSpeak3.php::class,
But I keep getting this error, and I couldn't find anything about it that helped me. I also tried to add it without .php at the end but that doesn't help either.
Fatal error: Uncaught ReflectionException: Class log does not exist in PATH-HERE\vendor\laravel\framework\src\Illuminate\Container\Container.php:734
I'll appreciate any help, thanks!
To use your class/library in Laravel, first you should put in your composer.json dependecy for that ts3phpframework
"require": {
"planetteamspeak/ts3phpframework" : "1.*"
}
Inside file app.php you need to do 2 things (something like this, dunno the proper name of alias and provider (be sure to do composer update before doing it)
First add provider (just a hint how to do it)
'providers' => [
ts3phpframework/ts3phpframeworkProvider::class
]
Second add alias (just a hint how to do it)
'aliases' => [
'ts3phpframework' => ts3phpframework\Facades\ts3phpframework::class,
]
If you won't be able to get this library with composer, then add it manually with a help of this. If you won't be able to find alias and provider, then create them manually with a help of this.
And at the end, very similar question already answered here
this question is asked many times and I did all the introductions I could found but I still get this error message.
I updated my config/app.php (
providers:
Intervention\Image\ImageServiceProvider::class,
aliases:
'Image' => Intervention\Image\Facades\Image::class,
and the composer.json
"intervention/image": "dev-master",
After this I did a composer update but my error message is still the same.. I'm using laravel 5
I did what the link says:
http://image.intervention.io/getting_started/installation
and yeah.. now I'm stuck
Another thing I dont understand is why they say I should write:
'Intervention\Image\ImageServiceProvider'
in the provider array. Why the ' '? All the other elements in my provider array are written like this:
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
so I removed the ' ' and addet ::class
the same with the aliases
I dont know if thats okay but maybe someone of you could help me
thanks for help
The ::class operator gives the fully qualified class name and was introduced in PHP 5.5 as you can see here. It's perfectly ok to use it if you have PHP >= 5.5.
I would suggest to check in the vendor directory if the package exists. I use "intervention/image": "^2.3" and everything's working great on L5.1
I am upgrading from 4.2 directly to 5.1 and run into problems with the Html and Form classes.
I followed the upgrade notes, and did
add "laravelcollective/html": "~5.0" to composer.json
composer update
add Collective\Html\HtmlServiceProvider::class to providers in app.php
add Form' => Collective\Html\FormFacade::class,
Html' => Collective\Html\HtmlFacade::class to aliases in app.php
But my views don't work. I get either Class HTML does not exist when using HTML::router or get Class html does not exist when using link_to_route
I also tried Illuminate\html instead of laravelcollective, I did a composer dump-autoload.
The complete errors:
ErrorException in Container.php line 736: Class html does not exist (View: C:\Dev\www\admin\resources\views\clubs\index.blade.php)
ReflectionException in Container.php line 736: Class html does not exist
What am I missing?
I tried everyone's answers and none of them worked for me for some reason. Ultimately I created a completely new laravel application, copied my code and then it started working, So though solved the actual problem remains a mystery.
Add in composer.json
"illuminate/html": "5.*"
and run composer update
Open your config/app.php
add under 'providers'
Illuminate\Html\HtmlServiceProvider::class,
add under 'aliases'
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
and under your blade templates, use as such
{!! HTML::style('assets/css/flatten.css') !!}
My solution in my case it was problem with CASE-Sensitive class name.
In my config/app.php (in aliases)
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
I am tried to use in view this code:
{!! HTML::mailto('mailto:example#example.com', 'example#example.com'); !!}
and that was an error:
"FatalErrorException in ccf70b1d0b9930d6c4e8f3859fff448f line 11: Class 'HTML' not found"
Name of class 'HTML' is CASE-Sensitive. You should use 'Html' as in your config (config/app.php) file.
Hope this help for some people.
Please change your blade file from this
{{ HTML::style('css/bootstrap.min.css') }}
to
{{ Html::style('css/bootstrap.min.css') }}
It's working.
A simple restart after composer update worked perfectly for me. I was looking for the answer, and got stuck at the same position. I'd suggest, run config:cache and cache:clear and restart the IDE. It will work.
My problem is solved, but the actual cause is still unknown. I have created a completely new laravel install and copied my source (all of it). The new application worked right away (after installing illuminate/html).
So you think I did something wrong with packages? That's what I thought, and then I did a diff on the two directories, only to find out they were identical. So it's a real mystery.
So, now everything is working, I simply renamed my new application and can continue.
I do know at some point I probably had both the collective and the illuminate versions of the HTML package installed. That's what most likely corrupted everything.
this is right way
If you try to use Form::open() or any of the Form methods in a fresh Laravel 5 install, you would get something like this:
http://laraveldaily.com/class-form-not-found-in-laravel-5/
I think I have found the solution.
In your app.php you have declared
'Form' => Illuminate\Html\FormFacade::class,
'Html' => Illuminate\Html\HtmlFacade::class,
While in your View you have called the same class as
{!! HTML::style('css/bootstrap.min.css') !!}
There is nothing wrong with the packages as the marked answer above but rather difference in capitalization of the word HTML as the previous documentation ver 5.0.*.
It should be
'Form' => Illuminate\Html\FormFacade::class,
'HTML' => Illuminate\Html\HtmlFacade::class,
Try it
php artisan cache:clear
php artisan clear-compiled
edit config/app.php
add this into providers
Collective\Html\HtmlServiceProvider::class,
and this into aliases
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
I work on project based on Laravel 4 and I will provide Rest API, want to authenticate request using OAuth 2,
I try https://packagist.org/packages/lucadegasperi/oauth2-server-laravel
but when try to run
Route::post('oauth/access_token', function()
{
return AuthorizationServer::performAccessTokenFlow();
});
I recieved
Class 'AuthorizationServer' not found
how to solve this? or there are another tool?
You haven't followed the installation instructions provided by the package.
oauth2-server-laravel on GitHub
Add the following line to your composer.json file:
"lucadegasperi/oauth2-server-laravel": "1.0.x"
Add this line of code to the providers array located in your app/config/app.php file:
'LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider',
And these lines to the aliases array:
'AuthorizationServer' => 'LucaDegasperi\OAuth2Server\Facades\AuthorizationServerFacade',
'ResourceServer' => 'LucaDegasperi\OAuth2Server\Facades\ResourceServerFacade',
Check if the AuthorizationServer is in another Namespace. If this is the case, use that Namespace before the class name, e.g. Namespace\AuthorizationServer::performAccessTokenFlow();
If that doesn't work, try adding a \ before the class name, like this: \AuthorizationServer::performAccessTokenFlow();
Did you try those commands?
composer update
composer dumpautoload
php artisan dump-autoload