3
votes

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

2
So you can't run php artisan in cmd? Have you checked your PATH?Anees Saban
did you add custom artisan command or install new vendor package recently?Bagus Tesa
Can you try to delete the bootstrap/cache/compiled.php and run composer install again?Lucas Silva
It's possible that one of your service providers is causing the problem. I'd look at the files inside your app/Providers directory. By default, they're fairly empty so check to see if you added any lines of code that might be causing the error.Thomas Kim
@ThomasKim :you are right i found it finallyMuhammad Atallah

2 Answers

2
votes

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

1
votes

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