PHP Artisan command does not work

Asked

Viewed 2,091 times

1

There was a demand in the job where I had to take an Laravel 5 project from a client and start changing it. I had some problems at the time to put to run, but now it is going, except for the command artisan, that doesn’t even work with when I type php artisan.

I need to make some changes, like creating models and controllers, but it just always gives the error

[Symfony Component Debug Exception Fatalerrorexception] Call-time pass-by-Ference has been Removed

I’m running the command in the project folder.

  • It’s probably a version incompatibility problem for PHP and Laravel.You know how to report their version.

  • Which version do you use? Which version? It is always important to provide details in the questions, so we can detect the problem.

  • PHP is 5.5.12, and I’m using Laravel 5

  • But other projects that I have Artisan works, only in this project that I took from a client that is giving this problem

  • It looks like old code stuff, huh. This system has always been in Laravel 5 or is it being migrated? Do you know which version of php it was running in?

  • Try to disable file errors artisan to see if it works. It’s a trick, but it’s worth a try. Do it in the first line of Artisan (after <?php of course)

  • Your mistake is related to a line more or less like this obj = & new Classe(); look for a &. They would not use a deprecated/removed resource or gambiarra.

  • @rray maybe he wrote it himself then, right?

  • You need to add more details to the @Isaiaslima question. Artisan does not tell you which file the execution error occurs in?

  • Where exactly do I look for the "&"? I did a Composer update, and presented the sequinte error in Artisan: "Script php Artisan clear-Compiled Handling the pre-update-cmd Event returned with an error [Runtimeexception] Error Output: ". Hence it shows many Artisan commands like "update [-prefer-source] [-prefer-dist]...

  • @Isaiaslima, do the following, try one composer update no-scripts. If it is, it is that there is a script added to the execution in the Composer that is giving way.

  • I just tried, even though it wasn’t, it was the same mistake I made above

  • @Isaiaslima I don’t think this error is in LARAVEL, but in some specific part of the application like controllers, models, services etc. All you should do now is search with the help of your code editor, IDE or LINUX command line tools by some standard like this: "&$". This is because the error derives from some function call where some parameter is passed with "&" in front of the variable/parameter. Find these occurrences and it will be solved.

  • @felipsmartins found out now that the project was done on Linux, and I’m trying to touch it on Windows... is there any problem regarding this condition? I’ve already had to make some changes to make the project work precisely because of this

  • @Isaiaslima No, there is no relationship, you can rest assured on that. The only exception is the care of file paths or fact that Linux is case-sensitive as to file names (but this shouldn’t be a problem since you are currently using windows)

Show 10 more comments

1 answer

4


Understand the problem:

<?php 

function spam(&$arg) {
    print $arg . "\n";
}

$var = 'PHP';

spam(&$var); # Causa erro
spam($var); # Okay!

I don’t think this error is in the Laravel framework itself - because someone would have already detected it -, but in some specific part of the application like controllers, models, services etc.

All you should do now is search (with help of your code editor, IDE or LINUX command line tools) for something like this: "&$" in function calls (but not in definitions) of the source code.
This is because the error derives from some function call where some parameter is passed with "&" in front of the variable/parameter. Find these occurrences and it will be solved.

In the editor sublimetext there is a tool called Find in files, the menu is: Find -> Find in Files... (Shift + Ctrl + F):

inserir a descrição da imagem aqui

EDIT

I noticed that you posted only part of the mistake. I’m pretty sure that if you post the rest of the message or Stacktrace (better) there will be the line where the error is and then you won’t even need to search the entire source code, just go on the line pointed at the error and make the adjustment. Please paste the stacktrace of the error.
A typical mistake like this is expected to return something like this:

PHP Fatal error: Call-time pass-by-Ference has been Removed in /home/Martins/teste.php on line 10

Fatal error: Call-time pass-by-Ference has been Removed in /home/Martins/teste.php on line 10

  • I just did this, but it showed a multitude of files, and some of them only with strange coding showing this "&$" combination, in addition to the other files created by Laravel himself. I started making changes to some files and I did a test with "php Artisan", and started giving error in the Timezone of the Compiled.php file, so I went back to everything as it was

  • Windows cmd only shows the error I passed. Is there any log where I can see this?

  • @Isaiaslima I’m not an Laravel developer, but I think logs can help a lot, if I’m not mistaken the log files are on: storage/logs

  • Boooooa, that’s right

Browser other questions tagged

You are not signed in. Login or sign up in order to post.