3

I know that there bunch of questions out there but mine doesn't seems fit in any.

I am working on laravel. php artisan was working fine an hour before. After that i just created a controller, a model and few views blade.

Now artisan simply won't work and no error at all. Even php artisan --version won't show anything.

I DIDN'T do any major changes like composer install, or update or install any new package. Neither any server configuration. It was just basic coding on controller , model and views.

Not sure what is causing this. What could be the reason and how shall i start debugging it?

cjmling
  • 6,896
  • 10
  • 43
  • 79
  • And you are sure that you are in your project folder? is there an artisan file inside? what is the correct error message? (with version?) – derdida Apr 09 '16 at 17:34
  • Make sure the problem is in artisan by running `php -v`. Also, look for errors in Laravel log files. – Alexey Mezenin Apr 09 '16 at 17:36
  • @derdida yup i am in the project folder using `ls` i could see my files and artisan file. What you mean by 'correct error message'? – cjmling Apr 09 '16 at 17:37
  • php -v running fine. There isn't seems to be anything wrong showing in laravel log :S – cjmling Apr 09 '16 at 17:42
  • 1
    Is debugging enabled for your application? Artisan is an integrated part of Laravel (meaning it's using a console application instance which will stop execution for any number of errors which may come from any part of your application). For example syntax errors in your application code can be a common culprit which will stop artisan from working, and if debugging is not enabled errors are not displayed (just logged). – Bogdan Apr 09 '16 at 18:13
  • 2
    Go to your project directory and try linting the entire directory by running this command `find -L ./ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l | grep "Errors parsing"`. If any syntax errors are present it will output the the first file that has an error, the line and the error. – Bogdan Apr 09 '16 at 18:21
  • @Bogdan Oh greatttt thanks alot for that command. Yes it was just because of a syntax error. That command help me locating the error. You may post as an answer , I will accept it. Thanks again :) – cjmling Apr 10 '16 at 05:27

2 Answers2

3

Artisan is an integrated part of Laravel, meaning it's using a console Application instance to run a command, and it will stop execution for errors which may come from any part of your application.

Syntax errors can be a common culprit that will stop artisan from working, and if debugging is not enabled errors are not displayed (just logged) so you get no output when running a command.

To search for syntax errors, go to your project directory and try linting the entire directory by running this command:

find -L ./ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l | grep "Errors parsing".

If any syntax errors are present, the command will output the first file that has an error, the line where it occurs and the error message.

Bogdan
  • 43,166
  • 12
  • 128
  • 129
1

In my case, there were no problems with files and syntaxes. But when I reinstalled the dependencies it worked.

composer install

run above command in your working directory and it worked.

Jay Mayu
  • 17,023
  • 32
  • 114
  • 148