CLass ''Form' Not Found - php

Class 'Illuminate\Html\HtmlServiceProvider' not found laravel 5.0

Simply follow 4 step
1) Go root directory find and edit composer.json - In that file write "illuminate/html": "^5.0" in require array.
2) Goto cmd and goto your folder directory and ** composer update **run this command
3) Next, add your new provider to the providers array of config/app.php:
'providers' => [
'Collective\Html\HtmlServiceProvider',
],
4) Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
],
After all this finished
Restart your laravel server :-- php artisan serve --port=8880
Now you can use Any Html tag in your view blade

For me, it was a much stupider mistake that I was making (although the provided answer works perfectly for the real issue).
What I was doing was continually editing the wrong composer file. I had one composer file outside of my laravel directory that was obviously not going to make any difference in my application.
When I did all of the recommended updated to the real composer file, everything worked fine.

Related

Why am I getting a "Class 'App\Providers\Form' not found" error in Laravel 5.5.43?

I did a Laravel 5.5.43 installation this morning with the following Composer command:
composer create-project laravel/laravel project-name
I then ran the following command in the project folder to install Laravel Collective:
composer require "laravelcollective/html":"^5.4.0"
I then added the following under providers in config/app.php:
Collective\Html\HtmlServiceProvider::class,
And I added the following under aliases in config/app.php:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
After that, I wanted to create custom form components, so I ran the following Artisan command:
php artisan make:provider FormServiceProvider
And in that new provider file, I added the following line to the boot method:
Form::component('customText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]);
Lastly, I added the following to providers in config/app.php:
App\Providers\FormServiceProvider::class,
When I do that though and refresh the Laravel instance from the browser, I get the following error:
Class 'App\Providers\Form' not found
However, if I add the following at the top of the FormServiceProvider.php file, then it works:
use Collective\Html\FormFacade AS Form;
I understand the concept of namespaces and why that makes the Form::component method in the boot method in the file properly work, but what I don't get is why I need to add that use line to the file at all.
Isn't the 'Form' => Collective\Html\FormFacade::class, line in the aliases array in the app.php file supposed to do that for me so I don't need to add the use line to the FormServiceProvider.php at all? What am I missing / doing wrong / not understanding?
Thank you.
I probably should just delete this question, but the simple answer was to add the following at the top of the FormServiceProvider.php file:
use Form;
Thanks.
Run below command:
php artisan config:cache
php artisan cache:clear

I'am getting an error --- In ProviderRepository.php line 208: Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

I'am new to laravel, and this is my first question because I could not find a solution anywhere.
I implemented JWT-token somehow and it worked until I mess it up. Now when I type php artisan serve I get that error, or when I try to publish. I tried everything like in question --- Laravel 5.6.26 Error- Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found --- but it won't work.
When I add in composer.json "tymon/jwt-auth": "^0.5.12" I get an error class LaravelServiceProvider not found, and when I change it to "tymon/jwt-auth": "^1.0.0-beta.3" or "tymon/jwt-auth": "^1.0.0-rc.2" then I ger error JWTAuthServiceProvider not found. I also tried composer require illuminate/auth but it won't work. Can I get some help please.
I had this same issue and I solved it by executing these commands
composer require illuminate/auth
composer require tymon/jwt-auth:"^1.0.0-rc.2"
composer update
Then
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"
You can safely remove from your app.php file
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class
You need to also add the alias to config/app.php like so:
'providers' => [
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
],
'aliases' = [
....
//other aliases
...
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuthFacades\JWTFactory::class`
]
and then include it at the top of the PHP file you want to use it in, like
use JWTAuth;
Try to delete config.php file from bootstrap/cache folder, it worked with me

How to fix Class 'PDF' not found in laravel

Encountered the following error in My Laravel app:
FatalErrorException in CollaboPDFController.php line 14: Class 'PDF' not found
This is my CollaboPDFController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use PDF;
class CollaboPDFController extends Controller
{
public function getPDF(){
$pdf = PDF::loadView('customer.customer'); //line 14
return $pdf->download('customer.customer');
}
//
}
How I can fix this?
You are using the wrong import. To use the PDF you want (probably laravel-dompdf) use:
use Barryvdh\DomPDF\Facade as PDF;
If you put 'PDF' => Barryvdh\DomPDF\Facade::class, in your config/app.php you could also use:
use \PDF;
or
\PDF::loadView('customer.customer');
First you have to require DOMPDF package
Step 1 :
composer require barryvdh/laravel-dompdf
Step 2 : In ..\config\app.php
'providers' => [
.....
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade::class,
]
Step 3 :
use \PDF;
Step 4 :
$pdf = PDF::loadView('pdf.report');
return $pdf->stream('report.pdf', array('Attachment' => 0));
You can run following commands after installing dompdf and set service provider and aliases in this file config/app.php
php artisan cache:clear and php artisan config:cache
Run the below command
composer require barryvdh/laravel-dompdf
In my case, I tried some of the examples above, but nothing worked.
However, I browsed the directory of the package located here:
project-folder>vendor>barryvdh>laravel-dompdf>src>Facade>Pdf.php
and I realized that the PDF alias created in the file >> app.php does not use the correct class.
So replace:
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade::class,
]
by:
'aliases' => [
.....
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,
]
I hope this will help you.
finally got the solutions actually it was My domPDF installation problem I find out it this way
php artisan cache:clear
// and
php artisan config:cache
and install domPDF again
this is problem with cache config.php within bootstrap folder.
shared hosting does not show full path of your [project folder]in shared hosting and if you want clear cache , you have to purchase their plugins. by the given solution you have no need to purchase any plugin or no need to clear / config cache of laravel 5.6 or more.
hit the URl in your browser it will give you error log. now oprn your error log and copy the path from the error log.
change all file paths in config.php of [your project folder ]/bootstrap/cache, [your project folder ]\bootstrap\cache or [your project folder ]* etc by the full path copied from error log like /mnt/stor2-wc1-dfw1/411797/622471/[yourdomain]/web/content/[your project folder ]

Laravel 5: How do i use forms in my 'Views'

Im am a beginner in Laravel, running version 5.2.16. I have been using PHP for quite some time but i have to get used to the MVC structure.
I have successfully added the optional dependancy for Html and Form, and they work.
I am trying to add a view where a client can register to my site, this view includes various forms. Now, when i try to route the view (register.blade.php) to the controller (RegisterController.php) I keep getting errors.
I suspect that I use the namespaces wrong, or that i doesn't "Use" the right things.
routes.php:
Route::get('register', 'RegisterController#showRegister');
RegisterController.php:
<?php
namespace App\Http\Controllers;
class RegisterController extends Controller {
public function showRegister()
{
return view('register');
}
}
In my config/app.php file i have added: (Should this be Illuminate instead of Collective?)
'providers' => [
...
Collective\Html\HtmlServiceProvider::class,
'aliases' => [
...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
After i have made these changes i run:
$ composer update
$ php artisan cache:clear
$ php artisan route:clear
However, this still gives med the error:
Fatal error: Class 'Form' not found (View: /Applications/MAMP/htdocs/myProject/resources/views/register.blade.php)
Any ideas?
My files are setup as this
Within Laravel versions < 5.0 FormFacade is already within your app/config/app.php but in Laravel versions > 5 you need to manually place the third party Facades like as
Begin by installing this package through Composer. Edit your project's composer.json file to require laravelcollective/html.
"require": {
"laravelcollective/html": "~5.0"
}
Next, update Composer from the Terminal:
composer update
Next, add your new provider to the providers array of config/app.php:
'providers' => [
// ...
'Collective\Html\HtmlServiceProvider',
// ...
],
Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
// ...
],
Docs

Laravel 5.2 - Will not recognise SimpleSMS new class provider / alias

I'm trying to install https://github.com/laggards/simple-sms to my laravel 5.2 project
Within require of my composer.json I have:
"guzzlehttp/guzzle": "~6.0",
"laggards/simple-sms": "~2"
In config/app.php under providers I have:
Laggards\SMS\SMSServiceProvider::class
Under aliases I have:
'SMS' => Laggards\SMS\Facades\SMS::class
At the top of my controller I have:
use SMS;
Within the controller:
SMS::send('This is my message', [], function($sms) {
$sms->to('+44123456789');
});
Error received:
Class 'SMS' not found
I have run the following to no success:
composer update
composer dump-autoload -o
composer dump-autoload
I would appreciate any help on this :)
Try this
Add Laggards\SMS\SMSServiceProvider::class in your config/app.php configuration file within the providers array.
Then Add 'SMS' => Laggards\SMS\Facades\SMS::class in your config/app.php configuration file within the aliases array.
After this run this command- composer dump-autoload
I followed this documentation and its working for me.
https://github.com/laggards/simple-sms
Problem seems to be that the documentation is wrong if you use the ~2 version the namespace is actually SimpleSoftwareIO instead of Laggards. So either use the dev-master version so it is Laggards or change the namespace to SimpleSoftwareIO. I'm not familiar with the package so not sure what the differences are.
You can see the correct documentation for ~2 version here.
Try
use \SMS;
or
use Laggards\SMS\Facades\SMS;

Categories