How can I get better output from Artisan commands? - laravel

[Symfony\Component\Debug\Exception\FatalThrowableError] Parse
error: syntax error, unexpected 'protected' (T_PROTECTED)
That's all I get. Any chance of a class name? The line causing the error? Anything at all that would help me narrow this down?

You can check last record in /storage/logs/laravel.log file.
Also, you could use route for the command to display full exception message:
Route::get('test-my-command', function() {
Artisan::call('my:command');
});

Related

Using Python shutil.copy to overwrite a file gives asyntax error

I am trying to overwrite one .png file with another using shutil.copy, but I keep getting a syntax error. The line in question is-
shutil.copy("/var/www/vk7krj/running/yoga.png", "/var/www/vk7krj/running/run4.png")
and the error is-
File "./latlong4.py", line 63
shutil.copy("/var/www/vk7krj/running/yoga.png","/var/www/vk7krj/running/run4.png")
SyntaxError: invalid syntax
with an up-arrow under the l in shutil
I have "import shutil" and also "from shutil import copyfile" in the head of the file.
Several hours of google searching has turned up nothing, so any assistance would be great.
Problem solved- turns out the error was incorrect indentation in an if-else earlier in the script- corrected that and the syntax error went away.

Codeigniter redirect function is having error

A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/adityanamansingh/kings.adityanamansingh.com/system/core/Exceptions.php:271)
Filename: helpers/url_helper.php
Line Number: 564
Backtrace:
File: /home/adityanamansingh/kings.adityanamansingh.com/application/controllers/admin/Login.php
Line: 34
Function: redirect
File: /home/adityanamansingh/kings.adityanamansingh.com/index.php
Line: 315
Function: require_once
Why am I receiving this error in my code.
It would be easy for everyone if you share your code.
You can look at this one which says
The error occurs when you have started outputting anything before
header redirect in PHP code. For example, check out any white spaces
after or before PHP tags, HTML tags printing before starting of PHP
tags or any output or debugging before the redirect function.
Also check for blank line before and after your closing php tag.
Hope it helps. Happy coding

How can I handle the error in load_svmlight_file?

when I run this code in mac:
x_train, y_train = load_svmlight_file("mq2008.train")
I get this error in bash:
-bash: syntax error near unexpected token `('
and if I run it in shell, I face this error:
NameError: name 'load_svmlight_file' is not defined
How can I solve this problem?
Welcome to StackOverflow!
IMO, you have a Python code and trying to replicate its output. If so, you should first load all Python-related imports first. This is what it means to NameError here, Python interpreter is not able to understand what it is, because this function is not part of its existing definitions it has.
If I may suggest, please spend some time to get the hands-on-learning of Python.

Installation of nvim-go fails with "Undefined variable: g:go#debug"

I'm switching to neovim and try to get nvim-go running. My Plug section in my init.vim looks like this:
call plug#begin('~/.vim/plugged')
Plug 'zchee/nvim-go', { 'do': 'make'}
Plug 'sebdah/vim-delve'
call plug#end()
If I open nvim and run PlugInstall, I get the following errors:
Error detected while processing
/home/domma/.vim/plugged/nvim-go/plugin/nvim-go. vim: line 20:
E121: Undefined variable: g:go#debug
I checked the file and the error makes sense. But I have no idea where this variable comes from, how it should be set. How can I fix this?
Temporary edit the line in /home/domma/.vim/plugged/nvim-go/plugin/nvim-go.vim: line 20
if g:go#debug -> if exists('g:go#debug')

Why does missing "require" / "include" call error_handler an extra time?

I have a custom error handler set up using set_error_handler. When I tried to include a file that doesn't exist, PHP calls error_handler one more time than it should:
<?php
error_reporting(E_ALL | E_STRICT);
set_error_handler(function($errno, $errstr, $errfile, $errline, $errcontext){
if(error_reporting() !== 0){
echo "<br>";
echo "<br>In Custom Error Handler...";
echo "<br>Err String: ", $errstr;
echo "<br>Passing to Default Handler...";
}
return false; // allow default
});
include("/missing_file.php"); // line 11
?>
Output:
In Custom Error Handler... // this is the extra error handler call
Err String: include(/missing_file.php)
[function.include]: failed to open stream: No such file or directory
Passing to Default Handler...
// the default handler does nothing, even though error_reporting is not zero
// Next Phase:
In Custom Error Handler...
Err String: include() [function.include]: Failed
opening '/missing_file.php' for inclusion
(include_path='.:/usr/lib/php:/usr/local/lib/php')
Passing to Default
Handler...
Warning: include() [function.include]: Failed opening
'/missing_file.php' for inclusion
in
/home/yccom/public_html/apr/test.php on line 11
The same behavior is observed with require.
For example, changing line 11 to require will give this output:
In Custom Error Handler... // this is the extra error handler call
Err String: require(/missing_file.php) [function.require]: failed to
open stream: No such file or directory
Passing to Default Handler...
// the default handler does nothing, even though error_reporting is
not zero
// Next Phase:
Fatal error: require() [function.require]: Failed opening required '/missing_file.php' in /home/yccom/public_html/apr/test.php on
line 11
What may be causing the error handler's additional call?
It's quite simple, really. PHP's lifecycle consists of 4 distinct phases:
Parsing
Compilation
Scanning
Execution
for your code to be parsed, all files that are included/required need to be fetched in the first phase, to translate the code into meaningful expressions. Your file doesn't exist, so a warning is issued.
Next, the compilation phase encounters the same include statement, and tries to convert the expressions into opcodes. The file doesn't exist, so a warning is issued.
Scanning translates code into tokens, which again cannot be done for the missing include file.
Execution time... The file cannot be executed because it is missing.
Why would PHP work like this? Isn't it stupid to blunder along, eventhough a file is missing?
In a way, yes, but include is used to include files that are non-critical to the script, if you really need that file's contents, you use require (but preferably require_once). The latter emits, as you stated, a fatal error, and stops everything dead in its tracks. That's what should happen if you're depending on another file for your code to function.
The require construct issues an E_COMPILER_ERROR, which effectively halts the compiler (not unlike __halt_compiler) at a given offset(the line where the failing require statement resides).
Check these slides for more details on each of the 4 main phases.
The reason why your code emits four warnings, is simply because PHP tries to include the file four times. Try running the script from the command line, but use strace:
$ strace -o output.txt php yourScript.php
open the output file, and see the internals of the Zend engine. Pay special attention to lines that look like:
lstat("/your/path/./file.php", 0x50113add8355) = -1//0x5... ~= 0xsomeaddress
You'll see where PHP goes looking for the file: it's all its include_path directories, the cwd, /usr/share/php, probably a pear or lib directory, and the include path you explicitly set.
I've gotten the idea to do this from this site, and based on the output I got, this seems to me to be the most plausible explanation as to why you see multiple errors.

Resources