1

I am absolutly new in PHP and in Laravel.

I am working on a Laravel controller class and I have put these 2 line

Console::info('username: ' + $userName); Console::info('password ' + $pswd);

to log what happens in the code.

So my entire controller class is:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Input;
use function GuzzleHttp\json_encode;
use function GuzzleHttp\json_decode;

use Illuminate\Support\Facades\Artisan;

class LoginBetriviusController extends Controller
{
    //------------------------------------------------------------------------------------
    //metodo richiamato al caricamento della web application - carica la pagina principale
    //------------------------------------------------------------------------------------
    public function index(){
        return view('login');       
    }

    //------------------------------------------------------------------------------------
    //TODO _ implementare chiamata per la LOGIN
    //------------------------------------------------------------------------------------
    public function doLogin(){

        $userName = Input::get('username');
        $pswd = Input::get('password');

        Console::info('username: ' + $userName);
        Console::info('password ' + $pswd);

        return view('dashboard-hotel');
    }
    //------------------------------------------------------------------------------------
    //FINE --- implementare chiamata per la LOGIN
    //------------------------------------------------------------------------------------
}

the prolem is that when enter in this method I am obtaining the following error message when try to execute the first Console::info method:

[Mon Jan 23 17:48:46 2017] PHP Fatal error:  Class 'App\Http\Controllers\Console' not found in C:\Users\Andrea\Documents\Betrivius
\WorkSpace\betriviusExtranet\app\Http\Controllers\LoginBetriviusController.php on line 34

Why? What am I missing? How can I fix this issue?

7
  • 1
    You'll have to namespace it or add a \ in front of it, depending on which Console class you're trying to use. Console is not a native Laravel class that I can see. Also, plus signs are not used for concatenation. Commented Jan 23, 2017 at 17:00
  • @aynber what have I to change? I am absolutly new in PHP... Commented Jan 23, 2017 at 17:01
  • 2
    If you're doing what I think you're trying to do (output the information somewhere so you can view it), use Alexey's answer. Commented Jan 23, 2017 at 17:02
  • @aynber in this way I have no error message but is not displayed into the bash console, why? Commented Jan 23, 2017 at 17:07
  • Because it's a PHP function, not javascript. Anything written with the Log class gets written to /storage/logs/ on the server. Commented Jan 23, 2017 at 17:07

2 Answers 2

1

You have to use the Log facade.

Namespace it with use Illuminate\Support\Facades\Log; and simply call Log::info('My log data');

Although I strongly discourage storing password data and especially in plain text!

Sign up to request clarification or add additional context in comments.

Comments

0

Use Log facade:

\Log::info('username: '.$userName);
\Log::info('password '.$pswd);

4 Comments

Sending plain plain text passwords to log? Mmm... delicious.
Doing in this way I obtain no error but the messages are not displayed into the shell. Why?
@AndreaNobili, good for you. What if this answer read (i.e. copy & paste) innocent children?
@AndreaNobili check storage/logs/laravel.log file permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.