Laravel with Blade Components throws Target Class View does not exist - php

I'm using Laradock with Laravel 7.24, and I can't make a Blade template component work.
I've followed the tutorial from the official documentation page, so, inside the docker-machine executed:
php artisan make:component Alert
And placed the component inside of the layout blade template:
<x-alert/>
But it throws the following error:
Target class [Illuminate\Support\Facades\App\View\Components\Alert]
does not exist. (View: /var/www/resources/views/layouts/app.blade.php)
Does anyone know what is the issue?
Thanks!

Experienced with the same problem.
First of all, remove the file from app/view/components this path and run
php artisan view:clear this command.
Hope it will work.

To use the component anonymous you need to delete class app/View/Components/Alert.php, deleting the view folder worked for me.

Related

How to a Make Component by artisan command without class?

I want to make a component in Laravel 8 by this command: php artisan make:component forms.input --view that means i want a component with only a Blade template and no class.
But i m Getting this ERROR: The "--view" option does not exist. Thanks for the tips
well, you may create a sub-directory under components let's say ...components/buttons.
Then just create a blade file representing your component for example round.blade.php.
use this component in any template like so <x-buttons.round /> and your component will be rendered correctly in your template.

How can I resolve RouteNotFoundException?

I'm trying to develope a program with Laravel, I have a problem with a Route, it shows me that is not define but it's already defined, also, I'm using Ajax.
This is the Error
This is my Ajax with URL and Route
And I tried to put the Route in that part of the code, but when I put there I get other problem.
I have tried this
Thank so much for your help.
After adding new route you need to clear cache. So run this commands:
php artisan cache:clear
php artisan route:cache
And check again
You have same controller method two time define and you did changed only route name? so it can return error. remove first route then it will work fine.
Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('client.schedules.destory');
Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('orders.schedules.store');
please remove Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('client.schedules.destory'); route.

I am not able to `use` or `namespace` in laravel helper file

I have created helper file in laravel. I want to use laravel functionalities.
I am not able to use use or namespace template in helper file.
code of helper file.
namespace App\Helpers;
class CommonFunctions {
public static function get_cat() {
}
}
I have linked this helper in config/app.php
When I use namespace in helper file then this error is displaying
Blade file code
Finally I found the issue.
Actually I am migrating site from laravel 5.2 to 5.7 and I was copying the old helper file to new that's why I got this error..
Previously I was using use and namespace together but after adding use statements only I solved the issue.
It might be the issue of namespace is not allowing in helper file, but in every solution and method of creating helper files there is namespace, so, I had never try to remove that line.
But now I got the solution...
Thanks for all who helped me.
Shishil Patel
I guess you have syntaxis error in your helper.
anyways try to execute php artisan config:clear and then fix all errors.
I have done everything the same way and I haven't found any problem.

laravel : php artisan not working

I know there is bunch of answer out there and none of them solved my problem. I am giving a try again in 2016 may be some one can help.
php artisan make:migration createxxxtable
don't show any error and it don't create the file
neither of these function output anything too.
php artisan list
php artisan help migrate
Its not new project. I had been working on this project earlier and it was working fine. Created bunch of migration.
I tried deleting everying inside vendor and do composer install and composer update still no luck.
I did tried command like dump-autoload , optimize , clear-compiled etc. too
Thanks
Ok found the solution. I don't know whats the reason. But it was because I was using url() helper in a custom config file i created in config folder. The config file and value of url and others works fine all across the website but it just break artisan command. I don't know why.
Removing that url() helper from my custom config file solved the problem.
Normally when this issue arises it's due to an error in your code. Check for these coporates
Could be a typo in your .env file
Could be a syntax error in your .env
Entering in wrong configuration(syntax error) in your config folder
can you please try php artisan does that open up the artisan commands?
If these doesn't show anything then check your path to project in console.

Laravel 4 Routes Not Working

I did look at the other Laravel Route questions, but nothing seems to work for me.
I am trying Laravel 4. I ran the command:
php artisan controller:make PhotoController
to create my controller. Then I added a route in my routes.php file as such:
Route::resource('photo', 'PhotoController');
When I go to localhost/photo, I see 404 Not Found.
Any ideas? I can see the root and /index.php, they both say "Hello World", so I know something is working.
You might need to run
composer dumpautoload
from the command line, so laravel knows the controller is there.
you can also try this:
php artisan dump-autoload

Categories