I try to make a controller with PHP artisan but when I run command php artisan make:controller TasksController I confront with following error:
In RouteAction.php line 84:
Invalid route action: [App\Http\Controllers\TaskController].
why this error to be occur?
Thanks in Advance.
The error occurs because you're trying to execute TaskController without action. You need to add action to the controller:
Route::get('task', 'TaskController#someAction');
If you don't have a similar route, it means routes are cached with some wrong route. Since Artisan commands do not work, clear this cache manually by deleting this file:
bootstrap/cache/routes.php
Related
how can we call controller method from console kernel.php in laravel. I am going to schedule one cron to so in schedule method I have write some code and going to call controller method.
When I am going to call it and run the command sudo php artisan schedule:run It gives me error like
[ReflectionException] Class
App\Http\Controllers\Auth\ReservationController does not exist
Check your namespace. It should be App\Http\Controllers\ReservationController.
I am using laravel-5.3. After renaming the app when I'm trying to start the server I'm getting the following error
[Symfony\Component\Debug\Exception\FatalThrowableError] Class
'App\Providers\AppServiceProvider' not found
What should i do? I am new at Laravel.
This is probably because you have your configuration cached. You can solve it with the artisan command 'config:cache':
php artisan config:cache
Before this, make sure that you have the correct namespaces in your application.
Suddenly when i type php artisan or any artisan command
i seen this message
[ErrorException]
Trying to get property of non-object
I tried the following
1- php artisan clear-compiled
2- To delete vendor directory and use composer install Or composer update
3- clone a standard Laravel app and put my files app dir and my config
and use composer commands but with step the error has changed to be
[ErrorException]
Trying to get property of non-object
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
Any Suggestions ?
Thanks
If I understand well, you have this issue when you use your app files. It probably means that you have some problem in constructor - you try to run function and the object is not initialized. You should not set up things in constructors (look for example at your controllers) or you will get some "strange" errors and your artisan won't work
After navigation on my app i found the issue in my ServiceProviderClass boot() method in particular when comment one method get data according to subDomain name artisan worked well
Laravel Doc hint for this method
This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework
for more read Laravel service provider
When I run php artisan route:list command then i am getting this error
The reason you're getting the error is this piece of code:
Auth::user()->name;
in your CategoryController's constructor.
When you run php artisan route:list, Laravel instantiates all controllers to check, if they declare a middleware - it's usually done in constructor by a call to middleware() method. At this point, there is no user session, therefore Auth::user() won't return anything, that's why you're getting an error trying to access name property on non-object.
You shouldn't access user object in the constructor, do that in action methods.
I am getting this error when I run it at http://localhost/myproject/public/vendor
the following is my routes:
Route::get('vendor', array('as'=>'vendorform','uses' => 'VendorController#create'));
Route::post('vendor', array('as'=>'saveVendor','uses' => 'VendorController#store'));
This is my create method in VendorController
public function create()
{
//
return view('vendor');
}
When I run php artisan route:list the route vendor is not listed
I have tried route:clear in the php artisan but this could not solve the problem.
vendor.blade.php is under /resources/views directory
Please any help. What's challenging me is that some routes configured in the same way works while others cannot work.
Please help.
You should not use public in url you run. You should run http://localhost/myproject/vendor url